I am trying to connect (or, more precisely, configure) a Linux application in OS X Snow Leopard (10.6.4). This is an application that sends binary code to the target equipment via a serial port. The application almost works, but I have an interesting problem with writing a serial port.
With all the same settings as Linux (115.2k - speed), OS X serial data transfer is apparently about 10 times or slower compared to Linux. What takes 3 seconds on Linux takes 30-40 seconds, and by that time the target firmware at the time of reception ends :).
Turning to the serial port write function, I see that it uses the select () system call to find out if the device (or rather the file descriptor) is ready to write data. Each write system call writes 1024 bytes of data in OS X and 1087 bytes of data in Linux (this is what returns the value of the record). My data size is about 50K for the first level binary (this is a small bootloader that can load a larger binary at the next level).
Pseudo code
select() configuration with 1s time out and observing the serial port file descriptor for write ready.
while(true)
{
rc=select(...)
if(rc>0){write(...) and other logic to get out of while if done}
if(rc==0){//try again}
if(rc<0){//error}
}
I noticed that in linux, entries happen all the time one by one. The sequence of entries and it exits the function in jiffy. But, in OS X, it looks like 3 records, and then the selection returns zero twice (after 2 seconds) again several records and the timing, etc. Etc., Which makes the function much slower.
Any clues?
:
termios lib API .