Update to civLabs BP scripting tool?

https://github.com/clvLabs/BusPirate

Seems like a good idea, but doesn’t seem to work too well with BP6.
Has anyone updated it?

1 Like

I believe that is for the old version 3.x Bus Pirate.

There are a couple options for scripting 5+. You can copy a similar style script with one command per line to the internal storage and run it with the script command. I will admit this is still dodgy in some areas (menu prompts can’t be auto filled).

If you just want a simple option to replay commands by Python I actually have just the thing. I use a script like this to do terminal output for the documentation. I can add some documentation and add it to its own repo.

Yes, it was developed for v3.6 Bus Pirate.
Their provided sample scripts I tried work flawlessly with the v3.6 BP.
Since I don’t know Python, if the problem isn’t in outdated command syntax I’m sunk.

For interfacing a PC to a 0-5V analog output for valve control, the v3.6 would probably work fine.
The missing part is a way to script the commands to the valve voltage.

Using a BP6 and storing the i2c output control sequence as a macro sounds attractive, but still needs a PC scripting method to invoke the macro.

I’d be interested in seeing your scripting tool.

1 Like

This might be an easy fun project for tomorrow. I’ll let you know when it’s available.

How badly do you need the output verification? That’s why the old one doesn’t work, it depends on some really old text in the browser.

We’d want at least enough of the response to see if it throws an error, if that’s what you’re asking.

1 Like

What kind of error specifically?

whatever the interpreter would throw during initial script construction, like these two:

I2C>[0x21 0zx0 0x0]
Warning: *Short or no pull-up
I2C START BIT
WRITE: 0x21 ACK
WRITE: 0x00 ACK
Syntax error at char 8

1 Like

Here is a fork of clvLabs’ Bus Pirate automation tool for 5+.

There were a couple issue with the old script, but none where what I suspected. For example I thought the old script actually caught and handled error messages, instead it just displays/logs everything.

  • Script was only sending \n after a command, we now require \r\n. This was the primary bug.
  • Script looks for >, assuming that is a prompt and time to send the next line. This is not a safe assumption. I modified it to use 0x03, as it is already the prompt indicator we use for autosnip/autocast.

Text below is from the forked git.

IMPORTANT NOTES

  • Reset feature has been removed. Bus Pirate v3.x had a USB to serial converter chip that remained connected while the Bus Pirate did a hardware reset. Bus Pirate 5+ uses a chip with built in USB, during reset the serial port disconnects/reconnects which this script has not been updated to handle.
  • Avoid VT100/ANSI color mode. The script does not handle VT100/ANSI color codes. Color will likely be shown in the terminal, but it will appear as garbage in the log. If the status toolbar is enabled it will inject additional voltage status updates in the terminal. Use the c command to show the configuration menu, then disable the VT100/ANSI color mode and the status toolbar. This can be done as part of your script.
  • Use the latest Bus Pirate firmware. The script requires a recent firmware that emits unprintable ASCII character 0x03 following each prompt.
  • Handle saved settings. Bus Pirate 5+ saves the settings for each mode, and prompts to use previous settings when entering a mode. For consistent scripting, have your script delete the mode configuration file before entering a mode. This can be done with rm bp<mode>.bp. For example rm bpi2c.bp to delete the I2C mode configuration file.
  • Consider using the autosnip.py tool. We use an autosnip tool for documentation generation. It can convert VT100 to HTML and save to one or more files. There is also an autocast tool for creating asciinema screen casts.

Updated sample.txt script

c           // show configuration menu
2           // ANSI color mode setting
1           // disable ANSI color mode
x           // exit configuration menu
rm bpi2c.bp // remove configuration file 
m i2c       // set I2C mode
400         // set I2C speed (400KHz)
1           // disable clock stretching
W 3.3       // start power supplies
P           // enable pull-ups
v           // read pin states
> D:10      // delay
w           // stop power supplies
v           // read pin states
m hiz       // set HiZ mode
  • Disables ANSI color mode
  • Removes the I2C mode configuration file
1 Like

Wow - that’s great.
May not be quite there yet.
Looks like the rm command is going to the ANSI configuration interpreter.
Using the 070b051 firmware.

/// disable ANSI color mode

1
<<< 1
<<< ANSI color mode set to Disable
<<<
<<< Configuration options
<<< 1. Language / Jezik / Lingua / 语言
<<< 2. ANSI color mode
<<< 3. ANSI toolbar mode
<<< 4. LCD screensaver
<<< 5. LED effect
<<< 6. LED color
<<< 7. LED brightness
<<< x. Exit
<<< >
/// remove configuration file so we don’t get stuck at the previous settings prompt
rm bpi2c.bp
<<< rm bpi2c.bp
<<< Error: Invalid option
<<< Configuration options
<<< 1. Language / Jezik / Lingua / 语言
<<< 2. ANSI color mode
<<< 3. ANSI toolbar mode
<<< 4. LCD screensaver
<<< 5. LED effect
<<< 6. LED color
<<< 7. LED brightness
<<< x. Exit
<<< >
/// set I2C mode
m i2c
<<< m i2c
<<< Error: Invalid option
<<< Configuration options
<<< 1. Language / Jezik / Lingua / 语言
<<< 2. ANSI color mode
<<< 3. ANSI toolbar mode
<<< 4. LCD screensaver
<<< 5. LED effect
<<< 6. LED color
<<< 7. LED brightness
<<< x. Exit
<<< >
/// set I2C speed (400KHz)
400
<<< 400
<<< Error: Invalid option
<<< Configuration options
<<< 1. Language / Jezik / Lingua / 语言
<<< 2. ANSI color mode
<<< 3. ANSI toolbar mode
<<< 4. LCD screensaver
<<< 5. LED effect
<<< 6. LED color
<<< 7. LED brightness
<<< x. Exit
<<< >

Looks like all it needed was to add an x command before the rm command in sample.txt.

/// disable ANSI color mode

1
<<< 1
<<< ANSI color mode set to Disable
<<<
<<< Configuration options
<<< 1. Language / Jezik / Lingua / 语言
<<< 2. ANSI color mode
<<< 3. ANSI toolbar mode
<<< 4. LCD screensaver
<<< 5. LED effect
<<< 6. LED color
<<< 7. LED brightness
<<< x. Exit
<<< >
x
<<< x
<<<
<<< Configuration file: Saved
<<<
<<< HiZ>
/// remove configuration file so we don’t get stuck at the previous settings prompt
rm bpi2c.bp
<<< rm bpi2c.bp
<<<
<<< HiZ>
/// set I2C mode
m i2c
<<< m i2c
<<<
<<< Mode: I2C
<<< I2C speed

1 Like

Thank you, I pushed an update to the docs and the sample.