Skip to content

Commit

Permalink
Add one char delay before switching TRX control, fixed warnings (#115)
Browse files Browse the repository at this point in the history
* Added one char to delay TRX control after write

* fixed warnings

* fix non working -r argument

---------

Co-authored-by: Daniel Beneš <[email protected]>
  • Loading branch information
Benik3 and Daniel Beneš authored Jan 10, 2025
1 parent 4a05446 commit 6b4248a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cfg_t cfg;
/* Configuration error message */
char cfg_err[INTBUFSIZE + 1];

#define CFG_ERR(s, v) snprintf(cfg_err, INTBUFSIZE, s, v)
#define CFG_ERR(...) snprintf(cfg_err, INTBUFSIZE, __VA_ARGS__)

/*
* Setting up config defaults
Expand Down Expand Up @@ -232,7 +232,7 @@ cfg_handle_param(char *name, char *value)
{
if (!strlen(value))
{
CFG_ERR("missing logfile value", value);
CFG_ERR("missing logfile value");
return 0;
}
else if (*value != '/')
Expand Down
7 changes: 3 additions & 4 deletions src/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ conn_write(int d, void *buf, size_t nbytes, int istty)
{
int rc;
fd_set fs;
struct timeval ts, tts;
long delay;

#ifdef TRXCTL
if (istty && cfg.trxcntl != TRX_ADDC)
Expand All @@ -266,7 +264,8 @@ conn_write(int d, void *buf, size_t nbytes, int istty)
#ifdef TRXCTL
if (istty && cfg.trxcntl != TRX_ADDC )
{
tty_delay(DV(nbytes, tty.bpc, cfg.ttyspeed));
// one char more delay to prevent too early GPIO switch on some HW
tty_delay(DV((nbytes + 1), tty.bpc, cfg.ttyspeed));
tty_set_rx(d);
}
#endif
Expand Down Expand Up @@ -839,7 +838,7 @@ conn_loop(void)
if (curconn->ctr >= MB_DATA_NBYTES)
{
/* compute request data length for fc 15/16 */
unsigned int len;
unsigned int len = 0;
switch (MB_FRAME(curconn->buf, MB_FCODE))
{
case 15: /* Force Multiple Coils */
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ main(int argc, char *argv[])
while ((rc = getopt(argc, argv,
"dh"
#ifdef TRXCTL
"ty:Y:"
"try:Y:"
#endif
#ifdef HAVE_TIOCRS485
"S"
Expand Down

0 comments on commit 6b4248a

Please sign in to comment.