HydraFW binary UART mode guide

Benjamin Vernoux edited this page Mar 16, 2017 · 5 revisions

HydraFW binary UART mode guide

This guide is updated towards firmware release HydraFW v0.7 Beta: HydraFW (HydraBus) v0.7-beta-0-gc5567bd 2016-04-16

Default STM32 UART used is uart2 see https://github.com/bvernoux/hydrafw/wiki/HydraFW-UART-guide#configuration-options for more details

Commands

Once the UART mode has been selected, the following commands are available :

  • 0b00000000 Return to main mode. Returns BBIO1
  • 0b00000010 Start echo UART RX
  • 0b00000011 Stop echo UART RX
  • 0b0001xxxx Bulk UART transfer
  • 0b0110xxxx Set UART speed

Command details

Start / Stop echo UART RX (0b00000010 / 0b00000011)

Once the local echo is started, each received byte on the UART will be sent to the user. Local echo is stopped by default. Returns 0x01

Bulk UART transfer (0b0001xxxx)

In this mode, the last 4 bits of the command define the number of bytes to write (from 1 to 16) (Command 0b00010000 will send 1 byte). Hydrabus will read the defined number of bytes, send a 0x01 (acknowledge) after each read bytes.

Set UART speed (0b0110xxxx)

This command sets the UART device bitrate. The four last bits will select the speed (int bits/sec) within the following list :

  • 0b0000 => 640
  • 0b0001 => 1200
  • 0b0010 => 2400
  • 0b0011 => 4800
  • 0b0100 => 9600
  • 0b0101 => 19200
  • 0b0110 => 31250
  • 0b0111 => 38400
  • 0b1010 => 115200

This commands returns 0x01 if successful, 0x00 in case of error.

Configure UART port (0b1000xx00)

The following value for the `xx``bits configure the following parameters :

  • 0b00 => No parity
  • 0b01 => Even parity
  • 0b10 => Odd parity

See https://github.com/bvernoux/hydrafw/wiki/HydraFW-UART-guide for explanation.

This commands returns 0x01 if successful, 0x00 in case of error.

Example script

This script will enable BBIO UART mode and listen to all incoming bytes

import serial
import os

ser = serial.Serial('/dev/hydrabus', 115200)

for i in xrange(20):
    ser.write("\x00")
if "BBIO1" not in ser.read(5):
    print "Could not get into bbIO mode"
    quit()

print "Into BBIO mode"

print "Switching to UART mode"
ser.write('\x03')
if "ART1" not in  ser.read(4):
    print "Cannot set UART mode"
    quit()

print "Setting speed"
ser.write('\x6a')
if ser.read(1) != '\x01':
    print "Error setting speed"
    quit()

print "Starting reader"
ser.write('\x02')
if ser.read(1) != '\x01':
    print "Error starting reader"
    quit()

while 1:
    print ser.read(1),
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.