Skip to main content

Topics

This section allows you to view all Topics made by this member. Note that you can only see Topics made in areas you currently have access to.

Topics - blue.zener

1
Bus Pirate Support / Possible latency issues with bin mode SPI / serial comms?
I think I may be encountering some latency issues with bin mode SPI under Linux. Admittedly I am trying to push a lot of data across the wire, but certainly not more than the bus pirate hardware can handle.

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
2
Bus Pirate Support / The Bus Pirate on Linux: From /dev/ttyUSB? to /dev/bus_pirate
This may be common knowledge, I'm note sure, but the other night I figured out how to create a UDEV rule to allow my bus pirate to be accessed in Linux via:

[font=courier:]/dev/bus_pirate[/font:]

irrespective of which USB port it is inserted into, or how many other ttyUSB? devices are also plugged into my system.

No more having to use dmesg to figure out which ttyUSB? the bus pirate is connected to today!

This could be of particular use when using a script to interact with the bus pirate using the new binmode interface.

I have posted a full tutorial-style write up of what I did here:

http://wiki.countercaster.com/The_Bus_Pirate_on_Linux:_From_/dev/ttyUSB%3F_to_/dev/bus_pirate

Hopefully this information will come in handy for other users of the bus pirate.

Cheers,

blue.zener

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01192283592session_write_close ( )...(null):0
20.01222415184ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01222415960Database_MySQL->query( ).../DatabaseHandler.php:119
40.05922554688Database_MySQL->error( ).../Db-mysql.class.php:273