[Twisted-Python] Question about SerialPort

Albert Brandl albert.brandl at weiermayer.com
Thu Jan 20 08:18:26 MST 2011


On Thu, Jan 20, 2011 at 08:42:58AM -0500, James Y Knight wrote:

> I don't think you'll ever be able to do this reliably in Python. At 
> 9600 baud, 3.5 characters is just about 275hz (9600/10/3.5). Linux 
> schedules process at around 500hz.

Well, that's bad news - I'll have to communicate with the SPS at 38400 
baud :-(...

> On the other hand, are you sure you need this? 
> http://www.libmodbus.org/ seems to have code which figures out what 
> length packets should be, and no code to detect a 3.5char delay between 
> packets. That seems much more reliable.

Thanks for the hint - I'll have a look. The code seems quite readable,
although I don't exactly _love_ reading C sources. But the idea that
one might still find out where a modbus message ends is intriguing -
I don't yet see how this might work.

> It also doesn't seem to have any code to ensure a 3.5char between sent 
> packets

Not sure about this - there is a structure called ctx which has a 
timeout_begin->tv_sec and timeout_begin->tv_usec (and a similar thing for 
timeout_end). On the first glance, this looks like variables for handling
the boundary. But I might be wrong.

Thanks & best regards,

Albert
-- 
Albert Brandl
Weiermayer Solutions GmbH      | Abteistraße 12, A-4813 Altmünster
phone: +43 (0) 720 70 30 14    | fax: +43 (0) 7612 20 3 56
web: http://www.weiermayer.com




More information about the Twisted-Python mailing list