1
Bus Pirate Support / Possible latency issues with bin mode SPI / serial comms?
My (Ruby) script is designed to drive a Nokia 3310 LCD. I plan to conribute my script (+ connection diagram) later in the week, once the code is beautified a little.
To write all 84x48 pixels requires 504 bytes of data. This takes 32 SPI bulk transfers, so 536 bytes are written to the bus pirate, and 536 are read back (32 acknowledges, 504 bytes of data).
My code writes bytes to the serial port, and reads bytes from it in lockstep -- write, read, write, read, etc. And I think this is where the latency issue occurs.
Basically, writing the 536 bytes is exceedingly slow -- it takes quite a few seconds. Roughly speaking, it should take only 1/20th of a second to send this data at 115200 baud. The bus pirate should be able to deal with the data very quickly, especially with 8MHz SPI mode enabled.
I think that the slowness comes from the OS having to timeout after each write, and then timing out after each read. It make sense that the OS would wait a little while for more data to arrive, given the overhead of constructing a USB transfer for a single byte; similarly, I can imagine that the FT232 would wait a little while to see if more data was on its way from the bus pirate.
I can't see an elegant way of getting around around this latency issue per se. I tried simply not reading from the serial port after each data byte in the bulk transfer is sent. Suddenly the 504 bytes are transferred instantaneously. But then on sending subsequent commands to the bus pirate, the script gets back this data (because it is buffered somewhere) when it should be getting back acknowledgements.
Perhaps, I am missing something about interfacing with serial ports? Has anyone been able to transfer this amount of data across SPI at speeds even close to the upper limit imposed by 115200 baud?
If, indeed, I am right about this, would it be possible to extend the protocol to allow a flag to be set to turn off the transmitting of reads in response to every SPI write? Many devices (including many LCDs) are write only devices, so this could come in handy in a lot of cases. This would mean that my script could stay in sync.
What do people think about this suggestion? Am I trying to push the bus pirate beyond its intended purpose?
Cheers,
blue.zener