Skip to main content
Topic: Script mode enhancements (Read 700 times) previous topic - next topic

Script mode enhancements

Hello everyone,,
I love my bus pirate. What a very useful little tool.
I was playing with the script mode and found some issues.

The first and most important is that the LSb/MSb setting is not honored when sending data in script mode. I didn't try receiving data but I assume it is the same. Data is always sent MSb - most significant bit first. I have tried both SPI and 3-wire and they share the same issue. As an example, let's say you configured to use SPI and LSb (command L) and send 0xA3 (decimal 163) while not in script mode. The bit pattern sent will be 1100 0101. Great. Now enter script mode (s) and do "10 SEND 163" and RUN. It will send the bit pattern 1010 0011. This is "correct" data, but bit reversed (MSb first). Obviously, the script engine should send the data in the bit order that has been configured. It would also be useful to have a command (say, "FLIPB") which would reverse the order of the bits in a byte. (for that matter, SWAPB would also be nice, to swap the two bytes of the 16-bit variable).

Another issue is the inability to forcefully break a script that has gotten into an infinite loop or which is stuck waiting on some external condition (waiting for specific data input that never comes). Conventionally, sending a Control-C (ascii ETX, End of Text) should terminate the operation. It would be extremely useful to have Bus Pirate respond to Control-C.

I wonder if we could expand beyond 1 kB for script storage?

The last issue is the silent removal of the script engine from v6.1, but I see that is resolved (or will be resolved) in v6.3, whenever that happens.

Re: Script mode enhancements

Reply #1
Hi Lincon.
Thank you very much for your posting, very much appreciated!
I made some tests with my Bus Pirate v3 using latest firmwares 09032019_OPT1_SAFE.hex and 09032019_OPT1_UNSAFE.hex (viewtopic.php?f=28&t=8498&start=120#p68332) built with the current repository and sadly it is like you wrote (actually I have even spotted another very severe bug that I have described as a separate issue on github), so I opened a dedicate issue on github:

In order to dig deeper the matter I would like to know more, especially about how you managed to evaluate the bit pattern sent while in script mode, hence how exactly you did set your Bus Pirate and the exact syntax you used in order to send data.
I write this because in SPI mode with the syntax "[163]" I can decode the data traffic sent by the Bus Pirate over the bus using a logic analyzer and confirming what you wrote, but in BASIC mode by running the script "10 SEND 163" I can not trigger.
Thanks a lot!

Be seeing you.