Skip to content

HydraFW binary UART mode guide

Baldanos edited this page Apr 9, 2016 · 15 revisions

#HydraFW binary UART mode guide

This guide is updated towards development firmware

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

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

##Command details

Start / Stop local echo (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.

###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 => 300
  • 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),

How to Flash/Use HydraFW

How to Build/Flash/Use HydraFW

Developer Getting-Started with HydraBus and STM32CubeIDE

Hardware

Firmware (hydrafw) performances

Firmware (hydrafw) Application guides

Firmware (hydrafw) guides

How to Help

Clone this wiki locally