No T3.5 delay between back to back sends?

13 views
Skip to first unread message

J.C. Wren

unread,
Sep 8, 2016, 12:57:21 PM9/8/16
to libmodbus
I've run into some behavior I'm not clear on.

It appears there's no enforcement of the T3.5 delay between sending messages, so if two calls are done back to back without inserting your own delay, the slave device will ignore the second write since it's listening for T3.5 of silence. Per the spec, T3.5 should be 1750 microseconds for any baud rate > 19200, otherwise T3.5 must be 3.5 times the character time.

In _modbus_rtu_send, the usleep() is using the character time times the length of the message plus the RTS time, but I think this is to allow the characters to clear the driver and UART FIFOs, correct?

Thanks!
--jc

Olivier Barthelemy

unread,
Sep 12, 2016, 5:34:59 AM9/12/16
to libm...@googlegroups.com
Yes as far as i remember, the library does not ensure minimal delay between two frames, it's up to you to ensure that delay is respected before calling modbus functions that will send data.
I think the library assumes that if you send a frame, you'll always wait for the answer before sending something else. So the delay between sent frames by the client is always respected, which also induces a delay between the frames of the respondes by the server. If you want to go faster than that (sending other request before receiving your previous response), you might have to be carefull of timing in your code
That modbus rtu_sleep mention must indeed be the wait for the sent data to actually be transfered, because it would be useless to start listening for an answer before that

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+unsubscribe@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.



--
Geovariances

Olivier BARTHELEMY Software development engineer
Geovariances, 49bis avenue Franklin Roosevelt - 77215 AVON CEDEX - FRANCE
| www.geovariances.com
Keep posted about Geovariances                  

J.C. Wren

unread,
Sep 12, 2016, 10:43:45 AM9/12/16
to libm...@googlegroups.com
I'm not trying to do anything faster than usual. I'm issuing a write followed by a read, and if I don't have the usleep() in there, or I decrease it below 1800, the read will fail (yes, my actual code has proper error checking and such, this is a minimal example to show the problem).

void updateRegister (void)
{
  uint16_t tab_reg [2];
 
  tab_reg [0] = 0;
  tab_reg [1] = 1;

  if (modbus_write_registers (ctx, 0, 2, tab_reg) == -1)
    errAndExit (ctx);

  usleep (1800);

  if (modbus_read_registers (ctx, 0, 2, tab_reg) == -1)
    errAndExit (ctx);
}

--jc

Save a life; adopt a shelter animal.

--
Vous recevez ce message, car vous êtes abonné à un sujet dans le groupe Google Groupes "libmodbus".
Pour vous désabonner de ce sujet, visitez le site https://groups.google.com/d/topic/libmodbus/LNhPvteDz7Q/unsubscribe.
Pour vous désabonner de ce groupe et de tous ses sujets, envoyez un e-mail à l'adresse libmodbus+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages