mirror of
https://github.com/3cky/mbusd.git
synced 2024-09-27 03:53:02 +02:00
Add new flag (-r) to support inverted RTS flow control\n\nThis is useful if you have a MAX485 connected to a Raspberry PI where you pull want RST low to transmit (#98)
This commit is contained in:
parent
b07681842f
commit
4ee7e8a834
@ -202,7 +202,11 @@ cfg_handle_param(char *name, char *value)
|
|||||||
}
|
}
|
||||||
else if (CFG_VALUE_MATCH("rts"))
|
else if (CFG_VALUE_MATCH("rts"))
|
||||||
{
|
{
|
||||||
cfg.trxcntl = TRX_RTS;
|
cfg.trxcntl = TRX_RTS_1;
|
||||||
|
}
|
||||||
|
else if (CFG_VALUE_MATCH("rts_0"))
|
||||||
|
{
|
||||||
|
cfg.trxcntl = TRX_RTS_0;
|
||||||
}
|
}
|
||||||
else if (CFG_VALUE_MATCH("sysfs_0"))
|
else if (CFG_VALUE_MATCH("sysfs_0"))
|
||||||
{
|
{
|
||||||
|
@ -139,7 +139,8 @@ usage(char *exename)
|
|||||||
" -A address : set TCP server address to bind (default %s)\n"
|
" -A address : set TCP server address to bind (default %s)\n"
|
||||||
" -P port : set TCP server port number (default %d)\n"
|
" -P port : set TCP server port number (default %d)\n"
|
||||||
#ifdef TRXCTL
|
#ifdef TRXCTL
|
||||||
" -t : enable RTS RS-485 data direction control using RTS\n"
|
" -t : enable RTS RS-485 data direction control using RTS, active transmit\n"
|
||||||
|
" -r : enable RTS RS-485 data direction control using RTS, active receive\n"
|
||||||
" -y : enable RTS RS-485 data direction control using sysfs file, active transmit\n"
|
" -y : enable RTS RS-485 data direction control using sysfs file, active transmit\n"
|
||||||
" -Y : enable RTS RS-485 data direction control using sysfs file, active receive\n"
|
" -Y : enable RTS RS-485 data direction control using sysfs file, active receive\n"
|
||||||
#endif
|
#endif
|
||||||
@ -218,7 +219,10 @@ main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
#ifdef TRXCTL
|
#ifdef TRXCTL
|
||||||
case 't':
|
case 't':
|
||||||
cfg.trxcntl = TRX_RTS;
|
cfg.trxcntl = TRX_RTS_1;
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
cfg.trxcntl = TRX_RTS_0;
|
||||||
break;
|
break;
|
||||||
case 'y':
|
case 'y':
|
||||||
cfg.trxcntl = TRX_SYSFS_1;
|
cfg.trxcntl = TRX_SYSFS_1;
|
||||||
|
12
src/tty.c
12
src/tty.c
@ -469,10 +469,13 @@ void sysfs_gpio_set(char *filename, char *value) {
|
|||||||
void
|
void
|
||||||
tty_set_rts(int fd)
|
tty_set_rts(int fd)
|
||||||
{
|
{
|
||||||
if ( TRX_RTS == cfg.trxcntl ) {
|
if ( TRX_RTS_1 == cfg.trxcntl ) {
|
||||||
int mstat = TIOCM_RTS;
|
int mstat = TIOCM_RTS;
|
||||||
ioctl(fd, TIOCMBIS, &mstat);
|
ioctl(fd, TIOCMBIS, &mstat);
|
||||||
} else if ( TRX_SYSFS_1 == cfg.trxcntl) {
|
} else if ( TRX_RTS_0 == cfg.trxcntl ) {
|
||||||
|
int mstat = TIOCM_RTS;
|
||||||
|
ioctl(fd, TIOCMBIC, &mstat);
|
||||||
|
} else if ( TRX_SYSFS_1 == cfg.trxcntl) {
|
||||||
sysfs_gpio_set(cfg.trxcntl_file,"1");
|
sysfs_gpio_set(cfg.trxcntl_file,"1");
|
||||||
} else if ( TRX_SYSFS_0 == cfg.trxcntl) {
|
} else if ( TRX_SYSFS_0 == cfg.trxcntl) {
|
||||||
sysfs_gpio_set(cfg.trxcntl_file,"0");
|
sysfs_gpio_set(cfg.trxcntl_file,"0");
|
||||||
@ -483,9 +486,12 @@ tty_set_rts(int fd)
|
|||||||
void
|
void
|
||||||
tty_clr_rts(int fd)
|
tty_clr_rts(int fd)
|
||||||
{
|
{
|
||||||
if ( TRX_RTS == cfg.trxcntl ) {
|
if ( TRX_RTS_1 == cfg.trxcntl ) {
|
||||||
int mstat = TIOCM_RTS;
|
int mstat = TIOCM_RTS;
|
||||||
ioctl(fd, TIOCMBIC, &mstat);
|
ioctl(fd, TIOCMBIC, &mstat);
|
||||||
|
} else if ( TRX_RTS_0 == cfg.trxcntl ) {
|
||||||
|
int mstat = TIOCM_RTS;
|
||||||
|
ioctl(fd, TIOCMBIS, &mstat);
|
||||||
} else if ( TRX_SYSFS_1 == cfg.trxcntl) {
|
} else if ( TRX_SYSFS_1 == cfg.trxcntl) {
|
||||||
sysfs_gpio_set(cfg.trxcntl_file,"0");
|
sysfs_gpio_set(cfg.trxcntl_file,"0");
|
||||||
} else if ( TRX_SYSFS_0 == cfg.trxcntl) {
|
} else if ( TRX_SYSFS_0 == cfg.trxcntl) {
|
||||||
|
Loading…
Reference in New Issue
Block a user