Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Automation of Binho Nova is made to be extremely easy using the Binho Python Package. This library also includes a command line interface for Nova such that it's possible to perform simple tasks like I2C or SPI transactions right from the command line / shell.
This library is still supported, but is not recommended for new designs.
Our initial python library was actually what would best be described as a 'wrapper'. It simply wrapped our ASCII commands into a set of equivalent Python functions. This served as well, but was a temporary solution to buy us time to produce a much more powerful library. We highly encourage everyone to use our new Python package which is packed with features:
Binho Python PackageThis page and the others in this section are left for historical purposes. This 'wrapper' library remains available and we'll continue to support customers using it, however all future improvements will be implemented only in our new library.
The packaged releases contains two libraries:
This library is essentially a wrapper for all of the commands presented in the documentation. The library is written in such a way to support multiple devices as well as by making use of threads.
This library provides a handful of functions which aid in device management, as in identifying COM ports and Binho devices attached to the host computer.
Here's where the releases live on PyPi:
The officially-supported Python library can easily be installed using pip:
This library is cross-platform and is intended for use with Python 3.x.
There are also many examples of the python libraries in action in the examples section of the support portal:
The library contains two classes, each with a distinct purpose. Please see the following pages for the documentation on each of these classes.
Functions to connect to a host adapter and interact with it:
Utility functions for device discovery and management:
pip install binho-host-adapterfrom binhoHostAdapter import binhoHostAdapter
from binhoHostAdapter import binhoUtilities
print("Demo Script with Binho Host Adapter Python Libraries")
print
utilities = binhoUtilities.binhoUtilities()
devices = utilities.listAvailableDevices()
if len(devices) == 0:
print("No Devices Found!")
exit()
elif len(devices) == 1:
COMPORT = devices[0]
print("Found 1 attached adapter @ " + devices[0])
print
else:
COMPORT = devices[0]
print("Found more than 1 attached adapter, using first device found on " + COMPORT)
print
print("Opening " + COMPORT + "...")
print
# create the binhoHostAdapter object
binho = binhoHostAdapter.binhoHostAdapter(COMPORT)
print("Connecting to host adapter...")
print(binho.getDeviceID())
printWe highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
This section shows the Binho Multi-Protocol USB Host Adapter in use in a number of typical applications:
I2C EEPROM Reading And WritingI2C Peripheral ModeSPI FRAM Reading And WritingI2C FRAM Reading And Writing1-Wire CommunicationSWI with Atmel Crypto ICsUART Bridge with I2CUsing Binho with PytestLooking for an example in a particular use case or test environment? Reach out to us at [email protected] and we'll do our best to create and publish a relevant example.
Have you done something new, interesting, and/or clever with your Binho Multi-Protocol USB Host Adapter and want to gain some street cred by sharing it with others? Send a link to your example to us at [email protected] and we'll include it here!
We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
The Binho Multi-Protocol USB Host Adapter paired with a Saleae Logic is the perfect combination for making hardware testing as simple as possible. Furthermore, Logic captures of UART, SPI, and I2C transactions can be exported and then replayed by Binho. This makes it very easy to recreate a test case or repeat a given stimuli that you've captured with Logic. Please see the samples below for each of the protocols.
We highly encourage everyone to use our which is packed with features. This library is still supported, but is not recommended for new design.
The binhoUtilities class contains several functions which help with managing serial ports, discovering devices, and connecting to specific devices. This class can be included in your code as show below.
One of the key benefits of using these helper functions is that care has been taken to ensure they work well across the various operating systems, particularly in regards to how serial ports are named and accessed.
We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
This example is a very brief demonstration of using SPI to read from and write to a SPI FRAM device. This particular examples uses the 64Kbit FRAM Breakout Board from Adafruit.
from binhoHostAdapter import binhoHostAdapter
from binhoHostAdapter import binhoUtilities
# Change this to match your COMPort
default_commport = "COM11"
print("SPI FRAM Example using Binho Host Adapter")
print("v1.0 -- Jonathan Georgino <[email protected]>")
print
utilities = binhoUtilities.binhoUtilities()
devices = utilities.listAvailableDevices()
if len(devices) == 1:
COMPORT = devices[0]
print("Found 1 attached adapter @ " + devices[0])
print
else:
COMPORT = default_commport
print("Found more than 1 attached adapter, using default port " + COMPORT)
print
print("Opening " + COMPORT + "...")
print
# create the binhoHostAdapter object
hostAdapter = binhoHostAdapter.binhoHostAdapter(COMPORT)
print(hostAdapter.setOperationMode(0, 'SPI'))
print(hostAdapter.setClockSPI(0, 1000000))
print(hostAdapter.setModeSPI(0, 0))
print(hostAdapter.setIOpinMode(0, 'DOUT'))
print(hostAdapter.setIOpinValue(0, 'HIGH'))
print(hostAdapter.beginSPI(0))
print(hostAdapter.setIOpinValue(0, 'LOW'))
print(hostAdapter.transferSPI(0, 0x9f))
print(hostAdapter.transferSPI(0, 0))
print(hostAdapter.transferSPI(0, 0))
print(hostAdapter.transferSPI(0, 0))
print(hostAdapter.transferSPI(0, 0))
print(hostAdapter.setIOpinValue(0, 'HIGH'))
print(hostAdapter.endSPI(0))
print(hostAdapter.clearBuffer(0))
print(hostAdapter.addByteToBuffer(0, 0x9f))
print(hostAdapter.beginSPI(0))
print(hostAdapter.setIOpinValue(0, 'LOW'))
print(hostAdapter.transferBufferSPI(0, 5))
print(hostAdapter.setIOpinValue(0, 'HIGH'))
print(hostAdapter.endSPI(0))
print(hostAdapter.readBuffer(0, 5))This function returns an array of currently available serial ports. The serial ports returned may or may not be a binho Multi-Protocol USB Host Adapter or some other device. See listAvailableDevices function below to get a list of serial ports related only to binho Multi-Protocol Host Adapters. Note that any serial ports which are currently opened will not be shown in the list.
Inputs:
This function takes no parameters.
Outputs:
This function returns an array of available serial ports as strings.
Example Usage:
This function returns an array of currently available serial ports that are associated with a binho Multi-Protocol USB Host Adapter. See listAvailablePorts function above to get a list of all available serial ports. Note that any serial ports which are currently opened will not be shown in the list.
Inputs:
This function takes no parameters.
Outputs:
This function returns an array of available serial ports as strings.
Example Usage:
This function returns an array which will either be either of length 0 (empty) or of length one, where the element will be a string containing the name of the serial port of the binho Multi-Protocol USB Host Adapter with the desired deviceID. This function is very useful when multiple host adapters are connected to the same computer.
Inputs:
This function takes 1 parameter, deviceID, as a string. It can either include or omit the "0x" prefix on the deviceID.
Outputs:
This function returns an array of serial ports as strings. Note that since the deviceIDs are globally unique, the returned array will have either zero or one element.
Example Usage:
from binhoHostAdapter import binhoUtilitiesfrom binhoHostAdapter import binhoUtilities
utilities = binhoUtilities.binhoUtilities()
availableCommPorts = utilities.listAvailablePorts()
print(availableCommPorts)
# Console Output (on Win10 PC):
# ['COM22', 'COM23']from binhoHostAdapter import binhoUtilities
utilities = binhoUtilities.binhoUtilities()
availableDevices = utilities.listAvailableDevices()
print(availableDevices)
# Console Output (on Win10 PC):
# ['COM22']from binhoHostAdapter import binhoUtilities
utilities = binhoUtilities.binhoUtilities()
targetDeviceCommPort = utilities.getPortByDeviceID('0xc59bb495504e5336362e3120ff032d2c')
print(targetDeviceCommPort)
# Console Output (on Win10 PC):
# ['COM22']
targetDeviceCommPort = utilities.getPortByDeviceID('c59bb495504e5336362e3120ff032d2c')
print(targetDeviceCommPort)
# Console Output (on Win10 PC):
# ['COM22']We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
This example demonstrates how to use Binho Nova as an I2C Peripheral device, with a device address of 0xA0 and operating in USEPTR mode of emulation.
import os
import subprocess
import shutil
import psutil
import sys
from binhoHostAdapter import binhoHostAdapter
from binhoHostAdapter import binhoUtilities
from time import sleep
# enter the deviceID of target test device
binhoID = '0x1c4780b050515950362e3120ff141c2a'
utilities = binhoUtilities.binhoUtilities()
binhoComPorts = utilities.getPortByDeviceID(binhoID)
binhoComPort = 0
if len(binhoComPorts) == 0:
print("ERROR: No Binho Slave Device found!")
exit(1)
elif len(binhoComPorts) > 1:
print("ERROR: More than one Binho Slave Device found!")
exit(1)
else:
binhoComPort = binhoComPorts[0]
print("Found Binho Slave Device on " + binhoComPort)
print("Opening " + binhoComPort + "...")
print()
# create the binhoHostAdapter object
binhoNova = binhoHostAdapter.binhoHostAdapter(binhoComPort)
print("Configuring Binho Nova I2C Slave with address of 0xA0")
binhoNova.setLEDColor('RED')
binhoNova.setOperationMode(0, 'I2C')
binhoNova.setPullUpStateI2C(0, "EN")
# assign the address of 0xA0
binhoNova.setSlaveAddressI2C(0, 0xA0)
# set the mode to USEPTR mode
binhoNova.setSlaveModeI2C(0, "USEPTR")
# load some initial values into registers 0x06 - 0x11
binhoNova.setSlaveRegisterI2C(0,0x06,0x00)
binhoNova.setSlaveRegisterI2C(0,0x07,0x06)
binhoNova.setSlaveRegisterI2C(0,0x08,0x05)
binhoNova.setSlaveRegisterI2C(0,0x09,0x00)
binhoNova.setSlaveRegisterI2C(0,0x0A,0x04)
binhoNova.setSlaveRegisterI2C(0,0x0B,0x00)
binhoNova.setSlaveRegisterI2C(0,0x0C,0x00)
binhoNova.setSlaveRegisterI2C(0,0x0D,0x00)
binhoNova.setSlaveRegisterI2C(0,0x0E,0x00)
binhoNova.setSlaveRegisterI2C(0,0x0F,0x00)
binhoNova.setSlaveRegisterI2C(0,0x10,0x00)
binhoNova.setSlaveRegisterI2C(0,0x11,0xFF)
# make all the registers readonly by setting WriteMasks to 0x00
binhoNova.setSlaveWriteMaskI2C(0, 0x06, 0x00)
binhoNova.setSlaveWriteMaskI2C(0, 0x07, 0x00)
binhoNova.setSlaveWriteMaskI2C(0, 0x08, 0x00)
binhoNova.setSlaveWriteMaskI2C(0, 0x09, 0x00)
binhoNova.setSlaveWriteMaskI2C(0, 0x0A, 0x00)
binhoNova.setSlaveWriteMaskI2C(0, 0x0B, 0x00)
binhoNova.setSlaveWriteMaskI2C(0, 0x0C, 0x00)
binhoNova.setSlaveWriteMaskI2C(0, 0x0D, 0x00)
binhoNova.setSlaveWriteMaskI2C(0, 0x0E, 0x00)
binhoNova.setSlaveWriteMaskI2C(0, 0x0F, 0x00)
binhoNova.setSlaveWriteMaskI2C(0, 0x10, 0x00)
binhoNova.setSlaveWriteMaskI2C(0, 0x11, 0x00)
# set the Pointer register to 0x00
binhoNova.setSlaveWriteMaskI2C(0, 'PTR', 0x00)
print(binhoNova.getSlaveWriteMaskI2C(0, 'PTR'))
# read back the configuration and print it out
for i in range(12):
print(binhoNova.getSlaveRegisterI2C(0,6+i))
print(binhoNova.getSlaveWriteMaskI2C(0,6+i))
print()
print()
print("It's Over!")
binhoNova.close()We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
The following script can be used to repeat UART streams captured and exported from Saleae Logic. After the capture is completed, export the Async Serial analyzer results as a csv file. You can follow this guide to export the file. The exported data should be in HEX-- Note that the base/radix of the exported data will match the current setting for display in the software.
Simply modify the parameters in lines 9-18 in the script below and then everything is ready to play back the file from the Binho Multi-Protocol USB Host Adapter.
For easy testing, here's an example export file from Saleae Logic that works with this script:
We highly encourage everyone to use our which is packed with features. This library is still supported, but is not recommended for new design.
The Binho Nova Multi-Protocol USB Host Adapter pairs elegantly with to implement an incredibly robust and efficient hardware and firmware testing platform.
We'll leave discussion of the features of pytest for their own very-thorough documentation, and just hit on a few tips to make it fast and easy to get started using it with your host adatper.
In order for the serial connection with your Binho Nova to persist through the entire test plan, you'll want to use a fixture. This is as easy as creating a conftest.py file in the test directory. Additionally, allow it accept command line parameters for device IDs, as this makes it easy to use multiple adapters on the same host computer.
We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
The following python script demonstrates how to use the SWI host Nova functionality of the Binho Multi-Protocol USB Host Adapter with the Atmel (now Microchip) ATSHA204A CryptoAuthentication IC. Communication with other devices from this family will be strikingly similar.
A special shout out to our friends at Sparkfun who produced a similar example above for their ATSHA204 Arduino Library many, many moons ago. This demo is built to match their example.
We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
The example below demonstrates how to read from and write to an I2C EEPROM. This particular demo uses the SparkX Qwiic 512Kbit EEPROM from Sparkfun.
Here's an example of a conftest.py file which creates two fixtures, one for each Binho Nova used in the testing:
In this fashion, the serial connections with the devices will be opened up at the beginning of the testing. Then, using these devices from within the test cases is simple, just pass them into each function that uses them as a parameter. Here's an example function to demonstrate this:
Writing automated hardware and firmware tests has never been easier!
def test_TestDevicesCommCheck(self, dut, testFixture):
response = dut.ping()
assert response == '-OK'
response = testFixture.ping()
assert response == '-OK'
response = dut.setLEDColor('YELLOW')
assert response == '-OK'
response = testFixture.setLEDColor('YELLOW')
assert response == '-OK'from binhoHostAdapter import binhoHostAdapter
from binhoHostAdapter import binhoUtilities
from datetime import datetime, timedelta, time
import math
import csv
uartIndex = 0
uartBaudRate = 9600
uartDataBits = 8
uartParity = 'NONE'
uartStopBits = 1
uartEscapeString = "+++UART0"
captureExportFile = 'C:\\Users\\Batman\\Desktop\\LogicExports\\uart_9600.csv'
binhoCommPort = 'COM27'
# ---- No Need to Change Anything Below Here ----
print("Opening " + binhoCommPort + "...")
print()
# create the binhoHostAdapter object
binho = binhoHostAdapter.binhoHostAdapter(binhoCommPort)
print("Connecting to binho host adapter...")
print()
print("Connected!")
print()
binho.setLEDColor('YELLOW')
print("Setting UART bus parameters:")
print()
binho.setOperationMode(0, 'UART')
print('BaudRate: ' + str(uartBaudRate))
binho.setBaudRateUART(uartIndex, uartBaudRate)
print('Databits: ' + str(uartDataBits))
binho.setDataBitsUART(uartIndex, uartDataBits)
print('Parity Bit: ' + str(uartParity))
binho.setParityUART(uartIndex, uartParity)
print('Stop Bits: ' + str(uartStopBits))
binho.setStopBitsUART(uartIndex, uartStopBits)
binho.setEscapeSequenceUART(uartIndex, uartEscapeString)
print()
print("Computing USB Transit time...")
t0 = datetime.now()
binho.ping()
binho.ping()
binho.ping()
binho.ping()
binho.ping()
t1 = datetime.now()
avgUSBTxTime = (t1 - t0)/5
print('Average USB Tx Time = ' + str(avgUSBTxTime) + 's')
print()
print("Beginning Replay...")
print()
binho.beginBridgeUART(uartIndex)
with open(captureExportFile) as captureExport:
capture_reader = csv.reader(captureExport, delimiter=',')
rowCount = 0
startTime = datetime.now()
prevTimestamp = startTime
prevRowTime = 0
for row in capture_reader:
if rowCount == 0:
# These are the column headers, just advance to the next row
rowCount += 1
print('Row#\tTimestamp\t\t\t\tData')
else:
currRowTime = float(row[0])
payload = int(row[1], 16)
deltaTimems = (currRowTime - prevRowTime) * 1000
#deltaTimems = 0.125 * 1000
#print('DeltaT: ' + str(deltaTimems))
#print('computed delta: ' + str(timedelta(0,0,0,math.floor(deltaTimems))))
while (datetime.now() - prevTimestamp) < timedelta(0,0,0,math.floor(deltaTimems)):
#nothing, sleep does not have high enough resolution
# print('WAITING ' + str(datetime.now() - prevTimestamp))
pass
binho.writeBridgeUART(chr(payload))
prevTimestamp = datetime.now()
prevRowTime = currRowTime
print(str(rowCount) + '\t' + str(prevTimestamp) + '\t\t' + str(payload))
rowCount += 1
binho.stopBridgeUART(uartEscapeString)
binho.ping()
print('Finished Replaying...')
print()
binho.setLEDColor('BLUE')
binho.close()
print('Goodbye!')from binhoHostAdapter import binhoHostAdapter
from binhoHostAdapter import binhoUtilities
# change this to your COM port
binhoTesterCommPort = 'COM22'
# create the binhoHostAdapter object
binhoTester = binhoHostAdapter.binhoHostAdapter(binhoTesterCommPort)
print("Connecting to binho host adapter tester...")
print()
swiIndex = 0
binhoTester.setLEDColor('CYAN')
binhoTester.setOperationMode(0, 'SWI')
binhoTester.beginSWI(swiIndex, 0, True)
# Begin Wake/ID Example
binhoTester.sendTokenSWI(swiIndex, "WAKE")
print(binhoTester.receiveBytesSWI(swiIndex, 4))
# Begin Serial Number Example
binhoTester.setPacketOpCodeSWI(swiIndex, 0x02)
binhoTester.setPacketParam1SWI(swiIndex, 0x00)
binhoTester.setPacketParam2SWI(swiIndex, 0x0000)
binhoTester.sendPacketSWI(swiIndex)
print(binhoTester.receiveBytesSWI(swiIndex, 7))
binhoTester.setPacketOpCodeSWI(swiIndex, 0x02)
binhoTester.setPacketParam1SWI(swiIndex, 0x00)
binhoTester.setPacketParam2SWI(swiIndex, 0x0002)
binhoTester.sendPacketSWI(swiIndex)
print(binhoTester.receiveBytesSWI(swiIndex, 7))
binhoTester.setPacketOpCodeSWI(swiIndex, 0x02)
binhoTester.setPacketParam1SWI(swiIndex, 0x00)
binhoTester.setPacketParam2SWI(swiIndex, 0x0003)
binhoTester.sendPacketSWI(swiIndex)
print(binhoTester.receiveBytesSWI(swiIndex, 7))
# Begin MAC Challenge Example
print('clearing buffer')
print(binhoTester.clearPacketSWI(0))
data = [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF]
print(binhoTester.writeToBuffer(0, 0, data))
print(binhoTester.setPacketOpCodeSWI(swiIndex, 0x08))
print(binhoTester.setPacketParam1SWI(swiIndex, 0x00))
print(binhoTester.setPacketParam2SWI(swiIndex, 0x0000))
print(binhoTester.setPacketDataFromBufferSWI(swiIndex, 32, "BUF0"))
print(binhoTester.sendPacketSWI(swiIndex))
#these first two will return NG because not enough time passed for the execution of the above command
binhoTester.receiveBytesSWI(swiIndex, 0x23)
binhoTester.receiveBytesSWI(swiIndex, 0x23)
# this one will actually return the response we are looking for
print(binhoTester.receiveBytesSWI(swiIndex, 0x23))
print(binhoTester.setPacketOpCodeSWI(swiIndex, 0x08))
print(binhoTester.setPacketParam1SWI(swiIndex, 0x00))
print(binhoTester.setPacketParam2SWI(swiIndex, 0x0000))
binhoTester.setPacketDataSWI(swiIndex, 0, 0x00)
binhoTester.setPacketDataSWI(swiIndex, 1, 0x11)
binhoTester.setPacketDataSWI(swiIndex, 2, 0x22)
binhoTester.setPacketDataSWI(swiIndex, 3, 0x33)
binhoTester.setPacketDataSWI(swiIndex, 4, 0x44)
binhoTester.setPacketDataSWI(swiIndex, 5, 0x55)
binhoTester.setPacketDataSWI(swiIndex, 6, 0x66)
binhoTester.setPacketDataSWI(swiIndex, 7, 0x77)
binhoTester.setPacketDataSWI(swiIndex, 8, 0x88)
binhoTester.setPacketDataSWI(swiIndex, 9, 0x99)
binhoTester.setPacketDataSWI(swiIndex, 10, 0xAA)
binhoTester.setPacketDataSWI(swiIndex, 11, 0xBB)
binhoTester.setPacketDataSWI(swiIndex, 12, 0xCC)
binhoTester.setPacketDataSWI(swiIndex, 13, 0xDD)
binhoTester.setPacketDataSWI(swiIndex, 14, 0xEE)
binhoTester.setPacketDataSWI(swiIndex, 15, 0xFF)
binhoTester.setPacketDataSWI(swiIndex, 16, 0x00)
binhoTester.setPacketDataSWI(swiIndex, 17, 0x11)
binhoTester.setPacketDataSWI(swiIndex, 18, 0x22)
binhoTester.setPacketDataSWI(swiIndex, 19, 0x33)
binhoTester.setPacketDataSWI(swiIndex, 20, 0x44)
binhoTester.setPacketDataSWI(swiIndex, 21, 0x55)
binhoTester.setPacketDataSWI(swiIndex, 22, 0x66)
binhoTester.setPacketDataSWI(swiIndex, 23, 0x77)
binhoTester.setPacketDataSWI(swiIndex, 24, 0x88)
binhoTester.setPacketDataSWI(swiIndex, 25, 0x99)
binhoTester.setPacketDataSWI(swiIndex, 26, 0xAA)
binhoTester.setPacketDataSWI(swiIndex, 27, 0xBB)
binhoTester.setPacketDataSWI(swiIndex, 28, 0xCC)
binhoTester.setPacketDataSWI(swiIndex, 29, 0xDD)
binhoTester.setPacketDataSWI(swiIndex, 30, 0xEE)
binhoTester.setPacketDataSWI(swiIndex, 31, 0xFF)
print(binhoTester.sendPacketSWI(swiIndex))
#these first two will return NG because not enough time passed for the execution of the above command
binhoTester.receiveBytesSWI(swiIndex, 0x23)
binhoTester.receiveBytesSWI(swiIndex, 0x23)
# this one will actually return the response we are looking for
print(binhoTester.receiveBytesSWI(swiIndex, 0x23))
binhoTester.close()from binhoHostAdapter import binhoHostAdapter
from time import sleep
class Sparkfun_QwiicEEPROM:
def __init__(self, addr, pageWriteMs):
self.eeprom_address = addr;
self.eeprom_pageWriteTime_ms = pageWriteMs
def begin(self, adapter):
self.hostAdapter = adapter
def writePage(self, memAddress, pageData):
memAddressHigh = (memAddress >> 8)
memAddressLow = memAddress & 0xFF
fullAddress = [memAddressHigh, memAddressLow]
## load the address into the buffer
self.hostAdapter.writeToBuffer(0, 0, fullAddress)
## load the data into the buffer
self.hostAdapter.writeToBuffer(0, 2, pageData)
## I2C Start Transmission
self.hostAdapter.startI2C(0, self.eeprom_address)
## I2C Write Buffer
self.hostAdapter.writeFromBufferI2C(0, 34)
## I2C End Transmission
self.hostAdapter.endI2C(0)
## Clear the Buffer
self.hostAdapter.clearBuffer(0)
def readPage(self, memAddress):
memAddressHigh = (memAddress >> 8)
memAddressLow = memAddress & 0xFF
## Clear the Buffer
self.hostAdapter.clearBuffer(0)
## I2C Start Transmission
print(self.hostAdapter.startI2C(0, self.eeprom_address))
print(self.hostAdapter.writeByteI2C(0, memAddressHigh))
print(self.hostAdapter.writeByteI2C(0, memAddressLow))
## I2C End Transmission
print(self.hostAdapter.endI2C(0))
## Request the data
self.hostAdapter.readToBufferI2C(0, self.eeprom_address, 32)
print(self.hostAdapter.readBuffer(0, 32))
def pageWriteDelay(self):
return self.eeprom_pageWriteTime_ms / 1000.0
# Change this to match your COMPort
COMPORT = "COM27"
print("EEPROM Example using Binho Host Adapter")
print("v1.0 -- Jonathan Georgino <[email protected]>")
print()
# create the binhoHostAdapter object
binho = binhoHostAdapter.binhoHostAdapter(COMPORT)
eeprom = Sparkfun_QwiicEEPROM(0xA0, 1)
print("Connecting to host adapter...")
print(binho.getDeviceID())
print()
print("Configuring I2C settings...")
binho.setOperationMode(0, "I2C")
binho.setPullUpStateI2C(0, "EN")
binho.setClockI2C(0, 400000)
print("Ready!")
print()
eeprom.begin(binho)
currentMemoryAddress = 0x0000
print("Starting to write to the EEPROM ...")
for i in range(4):
print("Writing Page #" + str(i))
pageData = [0xAA+i, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0]
pageData += [0xAB+i, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1]
print("PageData=")
print(pageData)
eeprom.writePage(currentMemoryAddress, pageData)
currentMemoryAddress += 32
sleep(eeprom.pageWriteDelay())
print()
print()
currentMemoryAddress = 0
print("Starting to read to the EEPROM ...")
for i in range(4):
print("Reading Page #" + str(i))
eeprom.readPage(currentMemoryAddress)
currentMemoryAddress += 32
print()
print()
binho.close()from binhoHostAdapter import binhoHostAdapter
from binhoHostAdapter import binhoUtilities
import pytest
def pytest_addoption(parser):
parser.addoption(
"--dutID", action="store", default="0xc59bb495504e5336362e3120ff032d2c", help="dutID: the GUID of the device to perform the test on"
)
parser.addoption(
"--fixtureID", action="store", default="0xa917ec725150464a39202020ff172123", help="fixtureID: the GUID of the test fixture device"
)
@pytest.fixture(scope="session")
def dut(request):
# enter the deviceID of target test device
binho_test_deviceID = request.config.getoption('--dutID')
utilities = binhoUtilities.binhoUtilities()
binhoTesterCommPorts = utilities.getPortByDeviceID(binho_test_deviceID)
binhoTesterCommPort = 0
if len(binhoTesterCommPorts) == 0:
print("ERROR: No Binho Tester Device found!")
exit(1)
elif len(binhoTesterCommPorts) > 1:
print("ERROR: More than one Binho Tester Device found!")
exit(1)
else:
binhoTesterCommPort = binhoTesterCommPorts[0]
print("Found Binho Tester Device on " + binhoTesterCommPort)
print("Opening " + binhoTesterCommPort + "...")
print
# create the binhoHostAdapter object
testDevice = binhoHostAdapter.binhoHostAdapter(binhoTesterCommPort)
print("Connecting to binho host adapter tester...")
print
def teardown():
#print('--test device teardown')
testDevice.close()
request.addfinalizer(teardown)
return testDevice
@pytest.fixture(scope="session")
def testFixture(request):
# enter the deviceID of target test device
binho_test_deviceID = request.config.getoption('--fixtureID')
utilities = binhoUtilities.binhoUtilities()
binhoTesterCommPorts = utilities.getPortByDeviceID(binho_test_deviceID)
binhoTesterCommPort = 0
if len(binhoTesterCommPorts) == 0:
print("ERROR: No Binho Tester Device found!")
exit(1)
elif len(binhoTesterCommPorts) > 1:
print("ERROR: More than one Binho Tester Device found!")
exit(1)
else:
binhoTesterCommPort = binhoTesterCommPorts[0]
print("Found Binho Tester Device on " + binhoTesterCommPort)
print("Opening " + binhoTesterCommPort + "...")
print
# create the binhoHostAdapter object
testDevice = binhoHostAdapter.binhoHostAdapter(binhoTesterCommPort)
print("Connecting to binho host adapter tester...")
print
def teardown():
#print('--test device teardown')
testDevice.close()
request.addfinalizer(teardown)
return testDevice
We highly encourage everyone to use our which is packed with features. This library is still supported, but is not recommended for new design.
The example below demonstrates how to read from and write to an I2C FRAM. Beyond that, it's also an excellent example of how to port an open-source Arduino library into a python script that can utilize the Binho Multi-Protocol USB Host Adapter.
This example is uses a 256Kbit I2C FRAM (MB85RC256V / Fujitsu) breakout board from our friends over at Adafruit. You can purchase it .
For comparison's sake, you can see the Adafruit Arduino library that this example was ported from

from binhoHostAdapter import binhoHostAdapter
from binhoHostAdapter import binhoUtilities
MB85RC_DEFAULT_ADDRESS = 0xA0
MB85RC_SLAVE_ID = 0xF8
class Adafruit_FRAM_I2C:
# CONSTRUCTOR
def __init__(self, addr):
self.framInitialised = False
self.i2c_addr = addr
# PUBLIC FUNCTIONS
# initializes I2C and configures the chip
# call this function before doing anything else
def begin(self, adapter):
self.hostAdapter = adapter
# Make sure we're actually connected
manufacturerID = 0
productID = 0
deviceInfo = [manufacturerID, productID]
self.getDeviceID(deviceInfo)
manufacturerID = deviceInfo[0]
productID = deviceInfo[1]
deviceFound = True
if manufacturerID != 0x00A:
print("Unexpected Manufacturer ID: " + str(deviceInfo[0]))
deviceFound = False
if productID != 0x510:
print("Unexpected Product ID: " + str(productID))
deviceFound = False
# Everything seems to be properly initialized and connected
self._framInitialised = True;
return deviceFound
# Writes a byte at the specific FRAM address
def write8(self, framAddr, value):
self.hostAdapter.startI2C(0, self.i2c_addr)
self.hostAdapter.writeByteI2C(0, framAddr >> 8)
self.hostAdapter.writeByteI2C(0, framAddr & 0xFF)
self.hostAdapter.writeByteI2C(0, value)
self.hostAdapter.endI2C(0)
# Reads an 8 bit value from the specified FRAM address
def read8(self, framAddr):
self.hostAdapter.startI2C(0, self.i2c_addr)
self.hostAdapter.writeByteI2C(0, framAddr >> 8)
self.hostAdapter.writeByteI2C(0, framAddr & 0xFF)
self.hostAdapter.endI2C(0)
response = self.hostAdapter.readByteI2C(0, self.i2c_addr)
data = response.split()
if len(data) == 3:
return int(data[2])
else:
return 0
# Reads the Manufacturer ID and the Product ID frm the IC
def getDeviceID(self, deviceInfo):
self.hostAdapter.startI2C(0, MB85RC_SLAVE_ID)
self.hostAdapter.writeByteI2C(0, 0xA0)
self.hostAdapter.endI2C(0, True)
response = self.hostAdapter.readBytesI2C(0, MB85RC_SLAVE_ID, 3)
data =response.split()
if len(data) == 5:
deviceInfo[0] = (int(data[2]) << 4) + (int(data[3]) >> 4)
deviceInfo[1] = ((int(data[3]) & 0x0F) << 8) + int(data[4])
# Change this to match your COMPort
default_commport = "COM27"
print("I2C FRAM Example using Binho Host Adapter")
print("v1.0 -- Jonathan Georgino <[email protected]>")
print
utilities = binhoUtilities.binhoUtilities()
devices = utilities.listAvailableDevices()
if len(devices) == 1:
COMPORT = devices[0]
print("Found 1 attached adapter @ " + devices[0])
print
else:
COMPORT = default_commport
print("Found more than 1 attached adapter, using default port " + COMPORT)
print
print("Opening " + COMPORT + "...")
print
# create the binhoHostAdapter object
binhoDevice = binhoHostAdapter.binhoHostAdapter(COMPORT)
binhoDevice.setNumericalBase('10')
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, '1')
binhoDevice.setClockI2C(0, 1000000)
framMemory = Adafruit_FRAM_I2C(MB85RC_DEFAULT_ADDRESS)
if framMemory.begin(binhoDevice) == True:
# found the I2C FRAM
memData = [0 for x in range(32)]
for i in range(32):
memData[i] = framMemory.read8(i)
print(memData)
for i in range(32):
framMemory.write8(i, i*2)
for i in range(32):
memData[i] = framMemory.read8(i)
print(memData)
binhoDevice.close()
else:
# couldn't read the FRAM manufacturer and product ID bits
print("I2C FRAM not identified... check your connections?")
We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
This function sets the operation mode of a specific pin.
This function takes two parameters:
ioNumber, which is the index of the pin to be configured, can be 0 - 4.
mode, which is the desired operation mode for the pin. Valid modes include DIN(Digital Input), DOUT (Digital Output), AIN (Analog Input), AOUT (Analog Output), and PWM.
The host adapter will respond with '-OK' upon successful execution of the command.
This function gets the operation mode of a specific pin.
This function takes one parameter:
ioNumber, which is the index of the pin for which the mode is being queried.
The host adapter will respond with IO[n] followed by 'MODE' followed by the current mode of the specified IO pin. See the details for the command above for the possible values of MODE.
This function sets the PWM frequency of the provided IO pin. This function is only available on IO pins which support PWM output. Please see the ASCII command for additional info.
This function takes two parameters:
ioNumber, which is the index of the pin for which the PWM frequency shall be applied.
freq, which is the frequency in Hz. Acceptable range is from 750Hz to 80000Hz.
The host adapter will respond with '-OK' upon successful execution of the command.
This function gets the PWM frequency of the provided IO pin. This function is only available on IO pins which support PWM output. Please see the ASCII command for additional info.
This function takes one parameter:
ioNumber, which is the index of the pin for which the PWM frequency is being queried.
The host adapter will respond with 'IOn' followed by 'PWMFREQ' followed up the configured frequency in Hz upon successful execution of the command.
This function configures the given IO pin to be used as an interrupt source. Interrupts can be on rising edge, falling edge, or any edge. Additional information on which pins can be used as interrupts can be found on the ASCII command documentation.
This function takes two parameters:
ioNumber, which is the index of the pin which will be configured as an interrupt source.
intMode, which can be either RISE, FALL, CHANGE, or NONE.
The host adapter will respond with '-OK' upon successful execution of the command.
This function returns the currently configured interrupt settings for the provided IO pin.
This function takes one parameter:
ioNumber, which is the index of the pin for which the interrupt configuration is being queried.
The host adapter will respond with 'IO[n]' followed by 'INT' followed by the current configured interrupt mode.
This function sets the current value of the provided IO pin. Note that the meaning of value and the acceptable range and units depends on the currently configured MODE of the given IO pin. Please see the documentation of the ASCII command for additional information.
This function takes two parameters:
ioNumber, which is the index of the pin which will be set to the given value.
value, which can be :
0 or 1 when operating as a digital output,
The host adapter will respond with '-OK' upon successful execution of the command.
This function returns the current value of the provided IO pin. Note that the meaning of value and the acceptable range and units depends on the currently configured MODE of the given IO pin. Please see the documentation of the ASCII command for additional information.
This function takes one parameter:
ioNumber, which is the index of the pin for which the value is being queried.
The host adapter will respond with 'IO[n]' followed by 'VALUE' followed by the current value.
This function checks to see if an interrupt has been received from the host adapter. Note that this function does not involve any direct communication with the host adapter, rather it just checks to see if the python library has already received an interrupt from the device. More details about how interrupts are implemented can be found .
This function takes one parameter:
ioNumber, which is the index of the pin which is being checked for the interrupt flag.
This function returns either Trueor False . A value of True indicates that an interrupt event has occurred on the given IO pin.
This function clears the interrupt flag. Note that this function does not involve any direct communication with the host adapter, rather it just clears the interrupt flag in the python library. More details about how interrupts are implemented can be found .
This function takes one parameter:
ioNumber, which is the index of the pin which is being checked for the interrupt flag.
This function does not return any value.
0 to 1024 when operating as an analog output or PWM output
0V to 3.3V when operating as analog output
0% to 100% when operating as a PWM output
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setIOpinMode(0, 'AIN')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setIOpinMode(0, 'AIN')
binhoDevice.getIOpinMode(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setIOpinMode(0, 'PWM')
binhoDevice.setIOpinPWMFreq(0, 55000)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setIOpinMode(0, 'PWM')
binhoDevice.setIOpinPWMFreq(0, 55000)
binhoDevice.getIOpinPWMFreq(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setIOpinMode(3, 'DIN')
binhoDevice.setIOpinInterrupt(3, 'CHANGE')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setIOpinMode(3, 'DIN')
binhoDevice.setIOpinInterrupt(3, 'CHANGE')
binhoDevice.getIOpinInterrupt(3)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setIOpinMode(0, 'DOUT')
binhoDevice.setIOpinValue(0, 1)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setIOpinMode(0, 'DIN')
binhoDevice.getIOpinValue(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setIOpinMode(3, 'DIN')
binhoDevice.setIOpinInterrupt(3, 'CHANGE')
binhoDevice.getIOpinInterruptFlag(3)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setIOpinMode(3, 'DIN')
binhoDevice.setIOpinInterrupt(3, 'CHANGE')
binhoDevice.getIOpinInterruptFlag(3)
binhoDevice.clearIOpinInterruptFlag(3)We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
The following script can be used to repeat I2C transactions captured and exported from Saleae Logic. After the capture is completed, export the I2C analyzer results as a csv file. You can follow this guide to export the file. The exported data should be in HEX-- Note that the base/radix of the exported data will match the current setting for display in the software.
Simply modify the parameters in lines 9-15 in the script below and then everything is ready to play back the file from the Binho Nova Multi-Protocol USB Host Adapter.
For easy testing, here's an example export file from Saleae Logic that works with this script:
from binhoHostAdapter import binhoHostAdapter
from binhoHostAdapter import binhoUtilities
from datetime import datetime, timedelta, time
import math
import csv
i2cIndex = 0
i2cClockFreq = 400000
i2cPullEn = 'EN'
captureExportFile = 'C:\\Users\\Batman\\Desktop\\LogicExports\\i2c_eeprom.csv'
binhoCommPort = 'COM27'
# ---- No Need to Change Anything Below Here ----
print("Opening " + binhoCommPort + "...")
print()
# create the binhoHostAdapter object
binho = binhoHostAdapter.binhoHostAdapter(binhoCommPort)
print("Connecting to binho host adapter...")
print()
print("Connected!")
print()
binho.setLEDColor('YELLOW')
print("Setting I2C bus parameters:")
print()
binho.setOperationMode(0, 'I2C')
print('Clock Frequency: ' + str(i2cClockFreq))
binho.setClockI2C(i2cIndex, i2cClockFreq)
print('PullUps: ' + str(i2cPullEn))
binho.setPullUpStateI2C(i2cIndex, i2cPullEn)
print()
print("Computing USB Transit time...")
t0 = datetime.now()
binho.ping()
binho.ping()
binho.ping()
binho.ping()
binho.ping()
t1 = datetime.now()
avgUSBTxTime = (t1 - t0)/5
print('Average USB Tx Time = ' + str(avgUSBTxTime) + 's')
print()
print("Beginning Replay...")
print()
with open(captureExportFile) as captureExport:
capture_reader = csv.reader(captureExport, delimiter=',')
rowCount = 0
startTime = datetime.now()
prevTimestamp = startTime
prevRowTime = 0
currentPacketID = 0
deviceAddress = 0
payload = []
isReadPacket = True
for row in capture_reader:
if rowCount == 0:
# These are the column headers, just advance to the next row
rowCount += 1
print('PacketID#\tTimestamp\t\t\tAddress\tType\tLen(Bytes)')
else:
rowPacketID = row[1]
#check if packetID is empty
if rowPacketID == "":
#this is a single write command with no data to follow it, skip it
rowCount +=1
elif int(row[1]) == currentPacketID:
currRowTime = float(row[0])
deviceAddress = int(row[2],16)
payload.append(int(row[3], 16))
if row[4] == 'Write':
isReadPacket = False
else:
isReadPacket = True
rowCount += 1
else:
# starts a new packet, so do the transaction we loaded
deltaTimems = (currRowTime - prevRowTime) * 1000
#deltaTimems = 0.125 * 1000
#print('DeltaT: ' + str(deltaTimems))
print('Waiting ' + str(timedelta(0,0,0,math.floor(deltaTimems))) + ' until next packet transmission', end='\r')
while (datetime.now() - prevTimestamp) < timedelta(0,0,0,math.floor(deltaTimems)):
#nothing, sleep does not have high enough resolution
#print('WAITING ' + str(datetime.now() - prevTimestamp))
pass
if isReadPacket:
print(str(currentPacketID) + '\t\t' + str(datetime.now()) + '\t' + format(deviceAddress, '#02x') + '\tREAD\t' + str(len(payload)))
binho.readBytesI2C(i2cIndex, deviceAddress, len(payload))
else:
print(str(currentPacketID) + '\t\t' + str(datetime.now()) + '\t' + format(deviceAddress, '#02x') + '\tWRITE\t' + str(len(payload)))
binho.startI2C(i2cIndex, deviceAddress)
for dataByte in payload:
binho.writeByteI2C(i2cIndex, dataByte)
binho.endI2C(i2cIndex)
payload = []
prevTimestamp = datetime.now()
prevRowTime = currRowTime
currentPacketID = int(row[1])
currRowTime = float(row[0])
deviceAddress = int(row[2],16)
payload.append(int(row[3], 16))
if row[4] == 'Write':
isReadPacket = False
else:
isReadPacket = True
rowCount += 1
print('Finished Replaying...')
print()
binho.setLEDColor('BLUE')
binho.close()
print('Goodbye!')We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
The UART functionality is different than the other supported protocols, as it operates as a bridge, rather than transmitting commands only when functions are called. More information about this can be found in the User Guide.
This function sets the baudrate of the UART bridge. The default baudrate is 9600bps.
This function takes two parameters:
uartIndex, which is always 0 on Binho Nova host adapter.
baud, which can be set from 300 to 1000000bps.
The host adapter will respond with '-OK' upon successful execution of the command.
This function gets the baudrate of the UART bridge.
This function takes one parameter:
uartIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'UART0' followed by 'BAUD' followed by the configured baudrate in bps.
This function sets the number of databits for the UART connection. The default databits setting is 8 bits.
This function takes two parameters:
uartIndex, which is always 0 on Binho Nova host adapter.
databits, which can be set from 5 to 8 bits.
The host adapter will respond with '-OK' upon successful execution of the command.
This function gets the number of databits for the UART connection.
This function takes one parameter:
uartIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'UART0' followed by 'DATABITS' followed by the configured number of bits.
This function sets the Parity bit configuration for the UART connection. The default setting is None.
This function takes two parameters:
uartIndex, which is always 0 on Binho Nova host adapter.
parity, which can be set to NONE, ODD, or EVEN.
The host adapter will respond with '-OK' upon successful execution of the command.
This function gets the Parity bit configuration for the UART connection.
This function takes one parameter:
uartIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'UART0' followed by 'PARITY' followed by the currently configured parity setting.
This function sets the Stop bit configuration for the UART connection. The default number of stop bits is 1.
This function takes two parameters:
uartIndex, which is always 0 on Binho Nova host adapter.
stopbits, which can be set to either 1 or 2.
The host adapter will respond with '-OK' upon successful execution of the command.
This function sets the Stop bit configuration for the UART connection.
This function takes one parameter:
uartIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'UART0' followed by 'STOPBITS' followed by the current number of stop bits.
This function sets the escape sequence that can be used to break out of the UART bridge mode. The default escape sequence is +++UART0.
This function takes two parameters:
uartIndex, which is always 0 on Binho Nova host adapter.
escape, which must be a string of 6 to 16 characters.
The host adapter will respond with '-OK' upon successful execution of the command.
This function gets the currently configured escape sequence which can be used to close the UART bridge once it's been opened.
This function takes one parameter:
uartIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'UART0' followed by 'ESC' followed by the currently configured escape sequence.
This function opens up the UART bridge. Note that once the bridge is open, only reading and writing UART commands can be used until the UART bridge is closed.
This function takes one parameter:
uartIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command.
This function closes an opened UART bridge.
This function takes one parameter:
sequence, which is the 6 to 16 character long escape sequence.
The host adapter will respond with '-OK' upon successful execution of the command.
This function is used to transmit data over an open UART bridge. Note that this command does not directly communicate with the Binho Nova host adapter. Instead, it's writing the data to a transmit buffer within the python library. The python library will then transmit the data placed in the buffer.
This function takes one parameter:
data, which is the data to be written to the UART bus.
This function does not return any data.
This function is used to read data over an open UART bridge. Note that this command does not directly communicate with the Binho Nova host adapter. Instead, it's reading from the received data buffer within the python library.
This function takes no parameters.
This function returns any data that has been received over the UART bridge.
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.getBaudRateUART(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.setDataBitsUART(0, 8)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.setDataBitsUART(0, 8)
binhoDevice.getDataBitsUART(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.setDataBitsUART(0, 8)
binhoDevice.setParityUART(0, 'NONE')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.setDataBitsUART(0, 8)
binhoDevice.setParityUART(0, 'NONE')
binhoDevice.getParityUART(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.setDataBitsUART(0, 8)
binhoDevice.setParityUART(0, 'NONE')
binhoDevice.setStopBitsUART(0, 1)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.setDataBitsUART(0, 8)
binhoDevice.setParityUART(0, 'NONE')
binhoDevice.setStopBitsUART(0, 1)
binhoDevice.getStopBitsUART(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.setDataBitsUART(0, 8)
binhoDevice.setParityUART(0, 'NONE')
binhoDevice.setStopBitsUART(0, 1)
binhoDevice.setEscapeSequenceUART(0, '++ESCAPE++')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.setDataBitsUART(0, 8)
binhoDevice.setParityUART(0, 'NONE')
binhoDevice.setStopBitsUART(0, 1)
binhoDevice.setEscapeSequenceUART(0, '++ESCAPE++')
binhoDevice.getEscapeSequenceUART(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.setDataBitsUART(0, 8)
binhoDevice.setParityUART(0, 'NONE')
binhoDevice.setStopBitsUART(0, 1)
binhoDevice.beginBridgeUART(0)
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.setDataBitsUART(0, 8)
binhoDevice.setParityUART(0, 'NONE')
binhoDevice.setStopBitsUART(0, 1)
binhoDevice.beginBridgeUART(0)
binhoDevice.stopBridgeUART('+++UART0')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.setDataBitsUART(0, 8)
binhoDevice.setParityUART(0, 'NONE')
binhoDevice.setStopBitsUART(0, 1)
binhoDevice.beginBridgeUART(0)
binhoDevice.writeBridgeUART('Testing...')
binhoDevice.writeBridgeUART('more testing...')
binhoDevice.stopBridgeUART('+++UART0')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'UART')
binhoDevice.setBaudRateUART(0, 115200)
binhoDevice.setDataBitsUART(0, 8)
binhoDevice.setParityUART(0, 'NONE')
binhoDevice.setStopBitsUART(0, 1)
binhoDevice.beginBridgeUART(0)
binhoDevice.writeBridgeUART('Testing...')
binhoDevice.writeBridgeUART('more testing...')
print(binhoDevice.readBridgeUART())
binhoDevice.stopBridgeUART('+++UART0')We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
This function toggles whether or not the device echos back all the commands it receives. This really has no practical use in automation, but was included in the python library for the sake of completion. Turning the echo on is best for manual use in a terminal application which doesn't support local echo. Aside from this use case, it is not recommended to turn on echo. The default state of the device is with echo turned off.
Inputs:
This function takes no parameters.
Outputs:
The host adapter will respond with -OK upon successful execution of the command.
Example Usage:
This function provides for a simple way to solicit a response from the device. This can be useful when verifying the connection status with the device.
Inputs:
This function takes no parameters.
Outputs:
The host adapter will respond with -OK upon successful execution of the command.
Example Usage:
This function sets the mode of operation of the given adapter interface. This determines which protocol is being used, and therefore the pin functions. Any IO pins which are not assigned a function for the set protocol will continue to be available for concurrent use. The default operation mode on power up is IO.
Inputs:
This function takes 2 parameters, index, as an integer, and mode, as a string.
Note that for Binho Multi-Protocol USB Host Adapter, the only valid index is 0. This aspect of the protocol is design to support future products which may have more than one adapter interface.
The following list of values are valid values for mode parameter:
'I2C'
'SPI'
'UART'
'1-WIRE'
Outputs:
The host adapter will respond with -OK upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with -NG indicating the command did not execute successfully.
Example Usage:
This function gets the host adapter operation mode. This determines which protocol is being used, and therefore the pin functions. Any IO pins which are not assigned a function for the set protocol will continue to be available for concurrent use. The default operation mode on power up is IO.
Inputs:
This function takes 1 parameters, index, as an integer. Note that for Binho Multi-Protocol USB Host Adapter, the only valid index is 0. This aspect of the protocol is design to support future products which may have more than one adapter interface.
Outputs:
The host adapter will respond with one of the following responses:
-MODE [index] IO when the host adapter is in IO mode (default).
-MODE [index] I2C when the host adapter is in I2C mode.
-MODE [index] SPI when the host adapter is in SPI mode.
Example Usage:
This function sets the host adapter display base. This determines which radix is being used when data is sent back as ASCII characters. The supported numerical bases are binary, decimal, and hexadecimal. The default numerical base on power up is hex.
Inputs:
This function takes 1 parameter, base, as a string. The following list of values are valid for this parameter:
'BIN' or '2' sets the numerical base to base-2 (binary).
'DEC' or '10' sets the numerical base to base-10 (decimal).
'HEX' or '16' sets the numerical base to base-16 (hexadecimal).
Outputs:
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
Example Usage:
This function gets the host adapter display base. This determines which radix is being used when data is sent back as ASCII characters. The supported numerical bases are binary, decimal, and hexadecimal. The default numerical base on power up is hex.
Inputs:
This function takes no parameters.
Outputs:
The host adapter will respond with one of the following responses:
'-BASE BIN' when the host adapter is set to base-2 (binary).
'-BASE DEC' when the host adapter is set to base-10 (decimal).
'-BASE HEX' when the host adapter is set to base-16 (hexadecimal, default).
Example Usage:
This function sets the color of the internal RGB LED by setting the 8-bit red, green, and blue values.
Inputs:
This function takes three parameters, each as integer values:
r - red value expressed as 0 - 255
g - green value expressed as 0 - 255
b - blue value expressed as 0 - 255
Note that any value passed in less than 0 will be rounded up to 0. Conversely, any value passed in greater than 255 will be rounded down to 255.
Outputs:
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
Example Usage:
This function sets the color of the internal RGB LED by passing the name of a common color.
Inputs:
This function takes a single input parameter, color, as a string. The following list of values are valid inputs for this parameter:
'WHITE'
'RED'
'LIME'
'GREEN'
Outputs:
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
Example Usage:
This function returns the firmware version information of the host adapter.
Inputs:
This function takes no parameters.
Outputs:
The host adapter will respond with '-FWVER' followed by a space followed by the version.
Example Usage:
This function returns the hardware version information of the host adapter.
Inputs:
This function takes no parameters.
Outputs:
The host adapter will respond with '-HWVER' followed by a space followed by the version.
Example Usage:
This function performs a reset but will remain in the bootloader upon power-up. This will cause the USB connection to drop and re-enumerate. The host adapter will remain in the bootloader until a new firmware image is loaded, or until it is power cycled by unplugging it from USB and plugging it back in. Note that while the device is in the bootloader, it will act as a USB mass storage device, and will not respond to any of protocol commands.
Inputs:
This function takes no parameters.
Outputs:
The host adapter will respond with '-BTLDR OK' immediately before resetting.
Example Usage:
This function performs a reset. This will cause the USB connection to drop and re-enumerate. This also restores all device settings to their defaults.
Inputs:
This function takes no parameters.
Outputs:
The host adapter will respond with '-RESET OK' immediately before resetting.
Example Usage:
This function returns the globally-unique device identifier. This deviceID can be particularly useful to reference the device when using multiple host adapters on the same computer.
Inputs:
This function takes no parameters.
Outputs:
The host adapter will respond with '-ID 0x' followed by the 16-byte device ID. The ID will be displayed in hex regardless of the current Numerical Base setting.
Example Usage:
'SWI'
'IO'
-MODE [index] 1WIRE when the host adapter is in 1-WIRE mode.
-MODE [index] SWI when the host adapter is in SWI mode.
-MODE [index] UART when the host adapter is in UART mode.
'BLUE'
'YELLOW'
'CYAN'
'AQUA'
'MAGENTA'
'FUCHSIA'
'PURPLE'
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
# Toggle Echo On
binhoDevice.echo()
# Toggle Echo Off again
binhoDevice.echo()from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.ping()from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
# Change from IO mode to I2C mode
binhoDevice.setOperationMode(0, 'I2C')
# Now change from I2C mode to SPI mode
binhoDevice.setOperationMode(0, 'SPI')
# Let's go back to IO mode
binhoDevice.setOperationMode(0, 'IO')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
print(binhoDevice.getOperationMode(0))
#-MODE IO
# Change from IO mode to I2C mode
binhoDevice.setOperationMode(0, 'I2C')
print(binhoDevice.getOperationMode(0))
#-MODE I2C
# Now change from I2C mode to SPI mode
binhoDevice.setOperationMode(0, 'SPI')
print(binhoDevice.getOperationMode(0))
#-MODE SPIfrom binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
# Set the numerical base to each of the three supported bases
binhoDevice.setNumericalBase('BIN')
binhoDevice.setNumericalBase('DEC')
binhoDevice.setNumericalBase('HEX')
# These functions do the same as the three above
binhoDevice.setNumericalBase('2')
binhoDevice.setNumericalBase('10')
binhoDevice.setNumericalBase('16')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
print(binhoDevice.getNumericalBase())
#-BASE HEX
# Change from hex to binary
binhoDevice.setNumericalBase('BIN')
print(binhoDevice.getNumericalBase())
#-BASE BIN
# Now change to decimal / base-10
binhoDevice.setNumericalBase('DEC')
print(binhoDevice.getNumericalBase())
#-BASE DECfrom binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setLEDRGB(128,64,128)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setLEDColor('WHITE')
binhoDevice.setLEDColor('RED')
binhoDevice.setLEDColor('LIME')
binhoDevice.setLEDColor('GREEN')
binhoDevice.setLEDColor('BLUE')
binhoDevice.setLEDColor('YELLOW')
binhoDevice.setLEDColor('CYAN')
binhoDevice.setLEDColor('AQUA')
binhoDevice.setLEDColor('MAGENTA')
binhoDevice.setLEDColor('FUCHSIA')
binhoDevice.setLEDColor('PURPLE')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
print(binhoDevice.getFirmwareVer())
#-FWVER 0.3from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
print(binhoDevice.getHardwareVer())
#-HWVER 1.0from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
print(binhoDevice.resetToBtldr())
#-BTLDR OKfrom binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
print(binhoDevice.reset())
#-RESET OKfrom binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
print(binhoDevice.getDeviceID())
#-ID 0xc59bb495504e5336362e3120ff041d2cWe highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
The example below provides a basic demonstration of how to use the Binho Nova Multi-Protocol USB Host Adapter as both a UART bridge and an I2C controller to interact with the same DUT with both protocols.
from binhoHostAdapter import binhoHostAdapter
from binhoHostAdapter import binhoUtilities
binhoTesterCommPort = 'COM22'
# create the binhoHostAdapter object
binhoTester = binhoHostAdapter.binhoHostAdapter(binhoTesterCommPort)
print("Connecting to binho host adapter tester...")
print
print(binhoTester.setLEDColor('YELLOW'))
print(binhoTester.setOperationMode(0, 'UART'))
print(binhoTester.setBaudRateUART(0, 115200))
print(binhoTester.setDataBitsUART(0, 8))
print(binhoTester.setParityUART(0, 'NONE'))
print(binhoTester.setStopBitsUART(0, 1))
print(binhoTester.beginBridgeUART(0))
binhoTester.writeBridgeUART("Testing...")
binhoTester.writeBridgeUART("more more")
print(binhoTester.stopBridgeUART("+++UART0"))
print(binhoTester.ping())
binhoTester.setOperationMode(0, 'I2C')
binhoTester.setPullUpStateI2C(0, "EN")
binhoTester.setClockI2C(0, 400000)
print(binhoTester.startI2C(0, 100))
print(binhoTester.writeByteI2C(0, 15))
print(binhoTester.writeByteI2C(0, 25))
print(binhoTester.endI2C(0))
binhoTester.setOperationMode(0, 'UART')
print(binhoTester.beginBridgeUART(0))
binhoTester.writeBridgeUART("Second Burst")
binhoTester.writeBridgeUART("Same as the first")
binhoTester.writeBridgeUART("A whole lot louder")
binhoTester.writeBridgeUART("And a whole lot wurst")
print(binhoTester.stopBridgeUART("+++UART0"))
print(binhoTester.ping())We highly encourage everyone to use our which is packed with features. This library is still supported, but is not recommended for new design.
The following script can be used to repeat SPI transactions captured and exported from Saleae Logic. After the capture is completed, export the SPI analyzer results as a csv file. You can follow to export the file. The exported data should be in HEX-- Note that the base/radix of the exported data will match the current setting for display in the software.
Simply modify the parameters in lines 9-17 in the script below and then everything is ready to play back the file from the Binho Multi-Protocol USB Host Adapter.
For easy testing, here's an example export file from Saleae Logic that works with this script:
We highly encourage everyone to use our which is packed with features. This library is still supported, but is not recommended for new design.
The binhoHostAdapter class contains all the necessary functions to programmatically control / automate all of the functionality of your binho Multi-Protocol USB Host Adapter. This class can be included in your code as show below.
This class contains a multitude of functions split into several different categories. The documentation has been split up accordingly.
We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
The python script below demonstrates how to communicate with a DS2413, a dual-channel addressable switch IC. You can get one on an easy-to-use breakout board from our friends at Adafruit.
from binhoHostAdapter import binhoHostAdapterfrom binhoHostAdapter import binhoHostAdapter
from time import sleep
# change this to your COM port
binhoTesterCommPort = 'COM22'
print("Opening " + binhoTesterCommPort + "...")
print()
for i in range(3):
# create the binhoHostAdapter object
binhoTester = binhoHostAdapter.binhoHostAdapter(binhoTesterCommPort)
print("Connecting to binho host adapter tester...")
print()
oneWireIndex = 0
binhoTester.setLEDColor('CYAN')
binhoTester.setOperationMode(0, '1WIRE')
print(binhoTester.begin1WIRE(oneWireIndex, 0, True))
print(binhoTester.reset1WIRE(oneWireIndex))
print("Looking for a DS2413 on the bus")
print(binhoTester.resetSearch1WIRE(oneWireIndex))
print(binhoTester.search1WIRE(oneWireIndex))
print(binhoTester.getAddress1WIRE(oneWireIndex))
def write2413(state):
print('state orig: ' + str(state))
state |= 0xfc
print('state now: ' + str(state))
print('state inv: ' + str(~state + 256))
print('write2413 func begin')
print(binhoTester.reset1WIRE(oneWireIndex))
print(binhoTester.select1WIRE(oneWireIndex))
print(binhoTester.writeByte1WIRE(oneWireIndex, 90))
print(binhoTester.writeByte1WIRE(oneWireIndex, state))
print(binhoTester.writeByte1WIRE(oneWireIndex, ~state +256))
print(binhoTester.readByte1WIRE(oneWireIndex))
print(binhoTester.readByte1WIRE(oneWireIndex))
print(binhoTester.reset1WIRE(oneWireIndex))
write2413(3)
print('Sleeping for a hot sec ... ')
sleep(1.0)
print('doing it again...')
write2413(0)
print('Finished!')
binhoTester.close()from binhoHostAdapter import binhoHostAdapter
from binhoHostAdapter import binhoUtilities
from datetime import datetime, timedelta, time
import math
import csv
spiIndex = 0
spiClockFreq = 1000000
spiMode = 0
spiCSPinIONumber = 0
spiCSActiveLow = True
captureExportFile = 'C:\\Users\\Jonathan\\Desktop\\capture exports\\spi_example.csv'
binhoCommPort = 'COM27'
# ---- No Need to Change Anything Below Here ----
print("Opening " + binhoCommPort + "...")
print()
# create the binhoHostAdapter object
binho = binhoHostAdapter.binhoHostAdapter(binhoCommPort)
print("Connecting to binho host adapter...")
print()
print("Connected!")
print()
binho.setLEDColor('YELLOW')
print("Setting SPI bus parameters:")
print()
binho.setOperationMode(0, 'SPI')
print('Clock Frequency: ' + str(spiClockFreq))
binho.setClockSPI(spiIndex, spiClockFreq)
print('Mode: ' + str(spiMode))
binho.setModeSPI(spiIndex, spiMode)
print('CS Pin: IO' + str(spiCSPinIONumber))
binho.setIOpinMode(spiCSPinIONumber, 'DOUT')
if spiCSActiveLow:
binho.setIOpinValue(spiCSPinIONumber, 'HIGH')
else:
binho.setIOpinValue(spiCSPinIONumber, 'LOW')
print()
print("Computing USB Transit time...")
t0 = datetime.now()
binho.ping()
binho.ping()
binho.ping()
binho.ping()
binho.ping()
t1 = datetime.now()
avgUSBTxTime = (t1 - t0)/5
print('Average USB Tx Time = ' + str(avgUSBTxTime) + 's')
print()
print("Beginning Replay...")
print()
with open(captureExportFile) as captureExport:
capture_reader = csv.reader(captureExport, delimiter=',')
rowCount = 0
startTime = datetime.now()
prevTimestamp = startTime
prevRowTime = 0
currentPacketID = 0
payload = []
for row in capture_reader:
if rowCount == 0:
# These are the column headers, just advance to the next row
rowCount += 1
print('PacketID#\tTimestamp\t\t\tLen(Bytes)')
else:
#print('A: ' + row[0] + '\tB: ' + row[1] + '\tC: ' + row[2] + '\tD:' + row[3])
rowPacketID = row[1]
#check if packetID is empty
if rowPacketID == "":
#this is a single write command with no data to follow it, skip it
rowCount +=1
elif int(rowPacketID) == currentPacketID:
currRowTime = float(row[0])
payload.append(int(row[2], 16))
#print('Appening: ' + str(int(row[2], 16)) + ' row:' + str(rowCount))
rowCount += 1
else:
# starts a new packet, so do the transaction we loaded
deltaTimems = (currRowTime - prevRowTime) * 1000
#deltaTimems = 0.125 * 1000
#print('DeltaT: ' + str(deltaTimems))
print('Waiting ' + str(timedelta(0,0,0,math.floor(deltaTimems))) + ' until next packet transmission', end='\r')
while (datetime.now() - prevTimestamp) < timedelta(0,0,0,math.floor(deltaTimems)):
#nothing, sleep does not have high enough resolution
#print('WAITING ' + str(datetime.now() - prevTimestamp))
pass
print(str(currentPacketID) + '\t\t' + str(datetime.now()) + '\t' + '\t' + str(len(payload)))
binho.clearBuffer(0)
for dataByte in payload:
binho.addByteToBuffer(0, dataByte)
binho.beginSPI(spiIndex)
if spiCSActiveLow:
binho.setIOpinValue(spiCSPinIONumber, 'LOW')
else:
binho.setIOpinValue(spiCSPinIONumber, 'HIGH')
binho.transferBufferSPI(spiIndex, len(payload))
if spiCSActiveLow:
binho.setIOpinValue(spiCSPinIONumber, 'HIGH')
else:
binho.setIOpinValue(spiCSPinIONumber, 'LOW')
binho.endSPI(spiIndex)
currentPacketID += 1
payload = []
prevTimestamp = datetime.now()
prevRowTime = currRowTime
currRowTime = float(row[0])
payload.append(int(row[2], 16))
rowCount += 1
print('Finished Replaying...')
print()
binho.setLEDColor('BLUE')
binho.close()
print('Goodbye!')We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
This function starts the 1-WIRE host on the given IO pin. The 1-Wire protocol can be used on any of the IO pins, however it is especially convenient to use it on IO0 and IO2 as the internal pull-up resistor can be used thus eliminating the need for an external pull-up resistor.
This function takes three parameters:
oneWireIndex, which is always 0 on the Binho Nova host adapter.
pin, which can be any of the IO pins 0 through 4.
pullup, which can be either True or
The host adapter will respond with '-OK' upon successful execution of the command.
This function instructions the 1-Wire host to send the reset command. Sending the reset command is the first step of selecting a target device to communicate with.
This function takes one parameter:
oneWireIndexIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with '-OK' if the device on the 1-Wire bus asserted a presence pulse as a result of the result on the 1-WIRE bus. If the command fails or no device asserts a pulse after the reset, the function will return '-NG'.
This function sends one byte of data on the 1-WIRE bus.
This function takes two parameters:
oneWireIndexIndex, which is always 0 on Binho Nova host adapter.
powered, [optional], which will continue to leave the bus powered upon completion of the write if set to True.
The host adapter will respond with '-OK' upon successful execution of the command.
This function reads one byte of data from the 1-WIRE bus.
This function takes one parameter:
oneWireIndexIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with '1WIRE0' followed by 'READ' followed by one byte of data read from the bus.
This function selects the device whose address is currently in the internal address buffer to be the target for communication. The address in the internal address buffer is set by discovering the device via the search process.
This function takes one parameter:
oneWireIndexIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command.
This function allows one to skip the search process and enables communication with the device right away. This can only be used when there is only one 1-Wire device on the bus.
This function takes one parameter:
oneWireIndexIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command.
This function is used to power down the 1-WIRE bus.
This function takes one parameter:
oneWireIndexIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command.
This function returns the address that was found by performing a search.
This function takes one parameter:
oneWireIndexIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with '1WIRE0' followed by 'ADDR' followed by the 8-byte long address of the device discovered by the search.
This function begins the process of searching for devices on the 1-WIRE bus. The address of the found device will be stored in internal address buffer.
This function takes up to two parameters:
oneWireIndexIndex, which is always 0 on Binho Nova host adapter.
normalSearch, [optional], which can be True or False. In the case of False, an Alarm / Conditional search will be performed, which only returns devices in some sort of alarm state. See this for additional information on this topic.
The host adapter will respond with '-OK' upon successful execution of the command.
This function resets the search so that a new search can be started from the beginning.
This function takes one parameter:
oneWireIndexIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command.
This function searches the 1-WIRE bus for devices belonging to the same family code as the target.
This function takes two parameters:
oneWireIndexIndex, which is always 0 on Binho Nova host adapter.
target, which is a 1-byte long device family code for which to search.
The host adapter will respond with '-OK' upon successful execution of the command.
Falsepinfrom binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, '1WIRE')
binhoDevice.begin1WIRE(0, 0, True)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, '1WIRE')
binhoDevice.begin1WIRE(0, 0, True)
binhoDevice.reset1WIRE(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, '1WIRE')
binhoDevice.begin1WIRE(0, 0, True)
binhoDevice.reset1WIRE(0)
binhoDevice.resetSearch1WIRE(0)
binhoDevice.search1WIRE(0, True)
binhoDevice.reset1WIRE(0)
binhoDevice.select1WIRE(0)
binhoDevice.writeByte1WIRE(0, 0xAB)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, '1WIRE')
binhoDevice.begin1WIRE(0, 0, True)
binhoDevice.reset1WIRE(0)
binhoDevice.resetSearch1WIRE(0)
binhoDevice.search1WIRE(0, True)
binhoDevice.reset1WIRE(0)
binhoDevice.select1WIRE(0)
binhoDevice.readByte1WIRE(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, '1WIRE')
binhoDevice.begin1WIRE(0, 0, True)
binhoDevice.reset1WIRE(0)
binhoDevice.resetSearch1WIRE(0)
binhoDevice.search1WIRE(0, True)
binhoDevice.reset1WIRE(0)
binhoDevice.select1WIRE(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, '1WIRE')
binhoDevice.begin1WIRE(0, 0, True)
binhoDevice.reset1WIRE(0)
binhoDevice.skip1WIRE(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, '1WIRE')
binhoDevice.begin1WIRE(0, 0, True)
binhoDevice.reset1WIRE(0)
binhoDevice.depower1WIRE(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, '1WIRE')
binhoDevice.begin1WIRE(0, 0, True)
binhoDevice.reset1WIRE(0)
binhoDevice.resetSearch1WIRE(0)
binhoDevice.search1WIRE(0, True)
binhoDevice.getAddress1WIRE(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, '1WIRE')
binhoDevice.begin1WIRE(0, 0, True)
binhoDevice.reset1WIRE(0)
binhoDevice.resetSearch1WIRE(0)
binhoDevice.search1WIRE(0, True)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, '1WIRE')
binhoDevice.begin1WIRE(0, 0, True)
binhoDevice.reset1WIRE(0)
binhoDevice.resetSearch1WIRE(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, '1WIRE')
binhoDevice.begin1WIRE(0, 0, True)
binhoDevice.reset1WIRE(0)
binhoDevice.resetSearch1WIRE(0)
binhoDevice.targetSearch1WIRE(0, 0xAA)We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
This function sets the clock frequency of the I2C bus. The Binho Nova Multi-Protocol USB Host Adapter supports I2C bus speeds from 100kHz to 4MHz. Per the I2C specification, the common clock frequencies are 100kHz, 400kHz, and 1MHz, although it's possible to run the bus at other frequencies.
Inputs:
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
frequency, which is an integer value in Hertz in the range of 100000 to 4000000. Note that the frequency value is truncated to 1kHz resolution. For example, a frequency value of will 200800 will result in an I2C clock frequency of 200kHz.
Outputs:
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
Example Usage:
This function gets the clock frequency of the I2C bus. The Binho Nova supports I2C bus speeds from 100kHz to 4MHz. Per the I2C specification, the common clock frequencies are 100kHz, 400kHz, and 1MHz, although it's possible to run the bus at other frequencies.
Inputs:
This function takes one parameter:
i2cIndex, which is always 0 on Binho Nova host adapter.
Outputs:
The host adapter will respond with '-I2C0 CLK' followed by a space followed by the current I2C clock frequency in Hertz.
Example Usage:
This function is used to engage / disengage the 2.2kOhm internal pull-up resistors on the SDA and SCL signals.
Inputs:
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
state, which is the desired state of the pullup resistors, either 'EN' for enable or 'DIS' for disable. See the example below for additional acceptable values for convenience.
Outputs:
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
Example Usage:
This function is used to get the status of the 2.2kOhm internal pull-up resistors on the SDA and SCL signals, as in whether they are currently engaged or disengaged.
Inputs:
This function takes one parameter:
i2cIndex, which is always 0 on Binho Nova host adapter.
Outputs:
The host adapter will respond with '-I2C0 PULL' followed by a space followed by the current state of the pull-up resistors, either 'ENABLED' or 'DISABLED'.
Example Usage:
This function is used to scan a single address to determine if a slave device is present and responding.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
address, which is the address of the target peripheral device on the I2C bus.
The host adapter will respond with '-I2C0 SCAN' followed by a space followed by the address scanned, followed by the scan result, which will be either 'OK' or 'NG'.
This function is used to write a single byte to a peripheral device on the I2C bus.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
data, which is the value to write to the target slave device.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function is used to request a single byte from a peripheral device on the I2C bus.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
address, which is the address of the target peripheral device on the I2C bus.
The host adapter will respond with '-I2C0 RXD' followed by a space followed by the received byte. If no data is received or an error occurs during the read, the response will be 'NG'.
This function is used to request data from a peripheral device on the I2C bus. The maximum number of bytes in a single request is 256.
This function takes three parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
address, which is the address of the target peripheral device on the I2C bus.
numBytes, which is the number of bytes to request from the peripheral device.
The host adapter will respond with '-I2C0 RXD' followed by a space followed by the received bytes. If no data is received or an error occurs during the read, the response will be 'NG'.
This function is used to send data to a peripheral device on the I2C bus from the internal buffer.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
numBytes, which is the number of bytes to send from the internal buffer. The data from the buffer is sent beginning with index 0 in the buffer.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function is used to request data from a peripheral device on the I2C bus and receive it into BUF0. The maximum number of bytes in a single request is 256.
This function takes three parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
address, which is the address of the target peripheral device on the I2C bus.
numBytes, which is the number of bytes to request from the peripheral device.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function is used to start an I2C transmission to a target peripheral device on the I2C bus.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
address, which is the address of the target slave device on the I2C bus.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function ends an I2C transmission. It can be used to send a stop bit or a repeated start bit.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
repeat, which shall be set to True to send a repeated start bit, otherwise the transmission will be terminated with a stop bit.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function performs a write of 0 to 1024 bytes followed by a read of 0 to 1024 bytes in a single transaction. This function minimizes the number of round-trips between the PC and Nova in order to maximize I2C throughput. This function is highly recommended for reading/writing I2C memory devices or in any other application where multibyte transactions are frequently used.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
addr, which is the address of the target I2C peripheral device on the bus. Note the address must be formatted as 7bit address in hex, without the leading "0x".
stop, which is used to indicate a stop bit should be sent at the end of the transaction. 0 = no stop bit sent, 1 = terminate transaction with stop bit.
The host adapter will respond with '-OK' upon successful execution of the command if numRBytes is 0. If numRBytes > 0, then the response will be 'I2C0 RXD' followed by the received data in Hex. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function configures Nova to behave as an I2C peripheral device assigned to the provided address.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
address, which can be any valid 8-bit I2C peripheral device address.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function returns the address assigned to Nova while operating in I2C peripheral mode.
This function takes one parameter:
i2cIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'I2C0 SLAVE' followed by the configured device address upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function configures the behavior of the emulated I2C peripheral device. At this time, the Binho Nova I2C peripheral supports two modes of operation which allow it to behave like some of the most common I2C peripheral devices. Please see the description of the modes on the page.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
mode, which can be either USEPTR or STARTZERO.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function returns the configured mode of the emulated I2C peripheral device. At this time, the Binho Nova I2C peripheral supports two modes of operation which allow it to behave like some of the most common I2C peripheral devices. Please see the description of the modes on the page.
This function takes one parameter:
i2cIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'I2C0 SLAVE MODE' followed by either USEPTR or STARTZERO upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function configures the number of registers to emulate in the I2C peripheral device memory bank while operating in I2C peripheral mode.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
registerCount, which can be any integer value from 1 to 256.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function returns the number of registers being emulated in the I2C peripheral device memory bank while operating in I2C peripheral mode.
This function takes one parameter:
i2cIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'I2C0 SLAVE REGCNT' followed by the number of registers upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function sets the value stored in a given register in the emulated I2C peripheral device to the provided value while operating in I2C peripheral mode.
This function takes three parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
register, which can be any integer value from 0 to the number of registers configured in the device.
value, which can be any integer value from 0 to 255
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function returns the value stored in a given register in the emulated I2C peripheral device while operating in I2C peripheral mode.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
register, which can be any integer value from 0 to the number of registers configured in the device.
The host adapter will respond with 'I2C0 SLAVE REG' followed by the register number and the value stored in that register. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function sets the value of any register's writemask which is used to determine which bits in a register can be written to by an I2C controller on the bus.
This function takes three parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
register, which can be any integer value from 0 to the number of registers configured in the device.
mask, which can be any integer value from 0 to 255, where a 1 corresponds to granting write access to the corresponding bit in the register.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function returns the value of any register's writemask which is used to determine which bits in a register can be written to by an I2C controller on the bus.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
register, which can be any integer value from 0 to the number of registers configured in the device.
The host adapter will respond with '-I2C0 SLAVE WRITEMASK' followed by the mask value upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function sets the value of any register's readmask which is used to determine which bits in a register can be read from by an I2C controller on the bus. This can be used to emulate strobe bits in a register.
This function takes three parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
register, which can be any integer value from 0 to the number of registers configured in the device.
mask, which can be any integer value from 0 to 255, where a 1 corresponds to granting read access to the corresponding bit in the register.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function returns the value of any register's readmask which is used to determine which bits in a register can be read from by an I2C controller on the bus.
This function takes two parameters:
i2cIndex, which is always 0 on Binho Nova host adapter.
register, which can be any integer value from 0 to the number of registers configured in the device.
The host adapter will respond with '-I2C0 SLAVE READMASK' followed by the mask value upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
numRBytes, which is the number of bytes to read, from 0 to 1024.
numWBytes, which is the number of bytes to write, from 0 to 1024.
data, which is a string of hex characters that matches the length specified by numWBytes parameter.
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)
print(binhoDevice.getClockI2C(0))
#-I2C0 CLK 1000000from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)
# any of these calls are valid ways to engage the pull up resistors
binhoDevice.setPullUpStateI2C(0, 'EN')
binhoDevice.setPullUpStateI2C(0, 'ENABLE')
binhoDevice.setPullUpStateI2C(0, '1')
binhoDevice.setPullUpStateI2C(0, 'ON')
# any of these calls are valid ways to disengage the pull up resistors
binhoDevice.setPullUpStateI2C(0, 'DIS')
binhoDevice.setPullUpStateI2C(0, 'DISABLE')
binhoDevice.setPullUpStateI2C(0, '0')
binhoDevice.setPullUpStateI2C(0, 'OFF')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)
binhoDevice.setPullUpStateI2C(0, 'EN')
print(binhoDevice.getPullUpStateI2C(0))
#-I2C0 PULL ENABLED
binhoDevice.setPullUpStateI2C(0, 'DIS')
print(binhoDevice.getPullUpStateI2C(0))
#-I2C0 PULL DISABLEDfrom binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)
binhoDevice.setPullUpStateI2C(0, 'EN')
print(binhoDevice.scanAddrI2C(0, 0x42))
#-I2C0 SCAN 0x42 OKfrom binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)
binhoDevice.setPullUpStateI2C(0, 'EN')
binhoDevice.startI2C(0, 0x42)
binhoDevice.writeByteI2C(0, 0xFA)
binhoDevice.endI2C(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)
binhoDevice.setPullUpStateI2C(0, 'EN')
print(binhoDevice.readByteI2C(0, 0x42))
#-I2C0 RXD 0xABfrom binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)
binhoDevice.setPullUpStateI2C(0, 'EN')
print(binhoDevice.readBytesI2C(0, 0x42, 4))
#-I2C0 RXD 0xAB 0xAC 0xAD 0xAEfrom binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)
binhoDevice.setPullUpStateI2C(0, 'EN')
binhoDevice.clearBuffer(0)
binhoDevice.addByteToBuffer(0, 12)
binhoDevice.addByteToBuffer(0, 136)
binhoDevice.addByteToBuffer(0, 0)
binhoDevice.addByteToBuffer(0, 255)
binhoDevice.writeFromBufferI2C(0, 4)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)
binhoDevice.setPullUpStateI2C(0, 'EN')
binhoDevice.readToBufferI2C(0, 0x42, 4)
print(binhoDevice.readBuffer(0, 4))
#BUF0 12 136 0 255from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)
binhoDevice.setPullUpStateI2C(0, 'EN')
binhoDevice.startI2C(0, 0x42)
binhoDevice.writeByteI2C(0, 0xFA)
binhoDevice.endI2C(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)
binhoDevice.setPullUpStateI2C(0, 'EN')
binhoDevice.startI2C(0, 0x42)
binhoDevice.writeByteI2C(0, 0xFA)
binhoDevice.endI2C(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setClockI2C(0, 1000000)
binhoDevice.setPullUpStateI2C(0, 'EN')
#write 4 bytes, no read
binhoDevice.writeToReadFromI2C(0, 'A0', 1, 0, 4, 'DEADBEEF')
#write 2 bytes, read back 8 bytes
binhoDevice.writeToReadFromI2C(0, 'A0', 1, 8, 2, 'ABCD')
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, "EN")
binhoDevice.setSlaveAddressI2C(0, 0xA0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, "EN")
binhoDevice.setSlaveAddressI2C(0, 0xA0)
print(binhoDevice.getSlaveAddressI2C(0))from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, "EN")
binhoDevice.setSlaveAddressI2C(0, 0xA0)
binhoDevice.setSlaveModeI2C(0, "USEPTR")from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, "EN")
binhoDevice.setSlaveAddressI2C(0, 0xA0)
binhoDevice.setSlaveModeI2C(0, "USEPTR")
print(binhoDevice.getSlaveModeI2C(0))from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, "EN")
binhoDevice.setSlaveAddressI2C(0, 0xA0)
binhoDevice.setSlaveModeI2C(0, "USEPTR")
binhoDevice.setSlaveRegisterCount(0, 128)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, "EN")
binhoDevice.setSlaveAddressI2C(0, 0xA0)
binhoDevice.setSlaveModeI2C(0, "USEPTR")
binhoDevice.setSlaveRegisterCount(0, 128)
print(binhoDevice.getSlaveRegisterCount(0))from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, "EN")
binhoDevice.setSlaveAddressI2C(0, 0xA0)
binhoDevice.setSlaveModeI2C(0, "USEPTR")
binhoDevice.setSlaveRegisterCount(0, 128)
binhoDevice.setSlaveRegisterI2C(0, 0, 0xDE)
binhoDevice.setSlaveRegisterI2C(0, 1, 0xAD)
binhoDevice.setSlaveRegisterI2C(0, 2, 0xBE)
binhoDevice.setSlaveRegisterI2C(0, 3, 0xEF)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, "EN")
binhoDevice.setSlaveAddressI2C(0, 0xA0)
binhoDevice.setSlaveModeI2C(0, "USEPTR")
binhoDevice.setSlaveRegisterCount(0, 128)
binhoDevice.setSlaveRegisterI2C(0, 0, 0xDE)
binhoDevice.setSlaveRegisterI2C(0, 1, 0xAD)
binhoDevice.setSlaveRegisterI2C(0, 2, 0xBE)
binhoDevice.setSlaveRegisterI2C(0, 3, 0xEF)
print(binhoDevice.getSlaveRegisterI2C(0,2))from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, "EN")
binhoDevice.setSlaveAddressI2C(0, 0xA0)
binhoDevice.setSlaveModeI2C(0, "USEPTR")
binhoDevice.setSlaveRegisterCount(0, 128)
binhoDevice.setSlaveRegisterI2C(0, 0, 0xDE)
binhoDevice.setSlaveRegisterI2C(0, 1, 0xAD)
binhoDevice.setSlaveRegisterI2C(0, 2, 0xBE)
binhoDevice.setSlaveRegisterI2C(0, 3, 0xEF)
# Only the lower byte of register 1 is writeable
binhoDevice.setSlaveWriteMaskI2C(0, 1, 0x0F)
# Make Registers 2 and 3 READ-ONLY
binhoDevice.setSlaveWriteMaskI2C(0, 2, 0x00)
binhoDevice.setSlaveWriteMaskI2C(0, 3, 0x00)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, "EN")
binhoDevice.setSlaveAddressI2C(0, 0xA0)
binhoDevice.setSlaveModeI2C(0, "USEPTR")
binhoDevice.setSlaveRegisterCount(0, 128)
binhoDevice.setSlaveRegisterI2C(0, 0, 0xDE)
binhoDevice.setSlaveRegisterI2C(0, 1, 0xAD)
binhoDevice.setSlaveRegisterI2C(0, 2, 0xBE)
binhoDevice.setSlaveRegisterI2C(0, 3, 0xEF)
# Only the lower byte of register 1 is writeable
binhoDevice.setSlaveWriteMaskI2C(0, 1, 0x0F)
print(binhoDevice.getSlaveWriteMaskI2C(0, 1))from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, "EN")
binhoDevice.setSlaveAddressI2C(0, 0xA0)
binhoDevice.setSlaveModeI2C(0, "USEPTR")
binhoDevice.setSlaveRegisterCount(0, 128)
binhoDevice.setSlaveRegisterI2C(0, 0, 0xDE)
binhoDevice.setSlaveRegisterI2C(0, 1, 0xAD)
binhoDevice.setSlaveRegisterI2C(0, 2, 0xBE)
binhoDevice.setSlaveRegisterI2C(0, 3, 0xEF)
# Only the lower byte of register 1 is readable
binhoDevice.setSlaveReadMaskI2C(0, 1, 0x0F)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'I2C')
binhoDevice.setPullUpStateI2C(0, "EN")
binhoDevice.setSlaveAddressI2C(0, 0xA0)
binhoDevice.setSlaveModeI2C(0, "USEPTR")
binhoDevice.setSlaveRegisterCount(0, 128)
binhoDevice.setSlaveRegisterI2C(0, 0, 0xDE)
binhoDevice.setSlaveRegisterI2C(0, 1, 0xAD)
binhoDevice.setSlaveRegisterI2C(0, 2, 0xBE)
binhoDevice.setSlaveRegisterI2C(0, 3, 0xEF)
# Only the lower byte of register 1 is readable
binhoDevice.setSlaveReadMaskI2C(0, 1, 0x0F)
print(binhoDevice.getSlaveReadMaskI2C(0,1))We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
The host adapter includes a 256-byte buffer which can be used to optimize multi-byte read and writes using any of the supported communication protocols.
This function clears the entire buffer, setting all bytes to 0.
Inputs:
This function one parameter, index. There is only one buffer, so this will always be 0.
Outputs:
The host adapter will respond with '-OK' upon successful execution of the command.
Example Usage:
This function adds a single byte to the buffer. Note that the buffer automatically keeps track of / auto-increments the index as data is loaded.
Inputs:
This function takes two parameters:
index, the index of the buffer. There is only one buffer, so this will always be zero.
val, as 8-bit integer value.
Outputs:
The host adapter will respond with '-OK' upon successful execution of the command.
Example Usage:
This function reads out a given number of bytes from the buffer. Note that the bytes are not cleared out of the buffer after the read. They will remain in the buffer until they are overwritten or when the buffer is cleared.
Inputs:
This function takes two parameters:
index, the index of the buffer. There is only one buffer, so this will always be zero.
numBytes, an 8-bit integer value of the number of bytes to read from the buffer.
Outputs:
The host adapter will respond with 'BUF0' followed by numBytes of bytes read from the buffer separated by spaces.
Example Usage:
This function writes up to 32 bytes into the buffer in a single transaction, beginning at the startIndex index in the buffer. This provides for a faster way to fill the buffer when the data is predetermined, such as when programming memory devices.
Inputs:
This function takes three parameters:
index -- the index of the buffer. There is only one buffer, so this will always be zero.
startIndex -- the position in the buffer that the first byte should be stored. The index will be incremented for each of the following bytes.
values -- an array of up to 32 bytes of data to be loaded into the buffer beginning at the startIndex position.
Outputs:
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
Example Usage:
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.clearBuffer(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.addByteToBuffer(0, 12)
binhoDevice.addByteToBuffer(0, 136)
binhoDevice.addByteToBuffer(0, 0)
binhoDevice.addByteToBuffer(0, 255)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.addByteToBuffer(0, 12)
binhoDevice.addByteToBuffer(0, 136)
binhoDevice.addByteToBuffer(0, 0)
binhoDevice.addByteToBuffer(0, 255)
print(binhoDevice.readBuffer(0, 4))
#BUF0 12 136 0 255from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
# Fill the entire buffer as quickly as possible
for y in range(8):
data = []
for x in range(32):
data += [x + (y*32)]
binhoDevice.writeToBuffer(0, y*32, data)We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
This function sets the clock frequency of the SPI bus. The default clock frequency is 2MHz.
This function takes two parameters:
spiIndex, which is always 0 on Binho Nova host adapter.
clock, which is the desired frequency from 500000 Hz to 12000000 Hz in 1000 Hz steps.
The host adapter will respond with '-OK' upon successful execution of the command.
This function gets the currently configured clock frequency of the SPI bus.
This function takes one parameter:
spiIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'SPI0' followed by 'CLK' followed by the configured clock frequency in Hertz.
This function sets the SPI bus bit order. The bit order can be configured to either LSB first or MSB first. The default bit order setting is MSB first.
This function takes two parameters:
spiIndex, which is always 0 on Binho Nova host adapter.
order, which is the desired bit order, can be either LSBFIRST or MSBFIRST.
The host adapter will respond with '-OK' upon successful execution of the command.
This function gets the currently configured SPI bus bit order.
This function takes one parameter:
spiIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'SPI0' followed by 'ORDER' followed by the currently configured bit order.
This function sets the SPI bus mode of operation. SPI Modes 0, 1, 2, or 3 are determined by CPOL and CPHA. It's possible to set the mode directly, or to configure CPOL and CPHA independently to determine the mode setting. The default mode is 0.
This function takes two parameters:
spiIndex, which is always 0 on Binho Nova host adapter.
mode, which is the desired mode: 0, 1, 2, or 3.
The host adapter will respond with '-OK' upon successful execution of the command.
This function gets the currently configured SPI bus mode.
This function takes one parameter:
spiIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'SPI0' followed by 'MODE' followed by the currently configured mode of operation.
This function gets the current SPI bus Clock Polarity. Clock polarity indicates the idle condition of the clock signal. This is related to the SPI mode. It's possible to configure the CPOL setting directly by using this command, or indirectly by using the MODE command. The default value of CPOL is 0.
This function takes one parameter:
spiIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'SPI0' followed by 'CPOL' followed by the currently configured clock polarity value.
This function gets the current SPI bus Clock Phase. Clock Phase indicates when the data is valid in relation to the clock edges. This is related to the SPI mode. It's possible to configure the CPHA setting directly by using this command, or indirectly by using the MODE command. The default value of CPHA is 0.
This function takes one parameter:
spiIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'SPI0' followed by 'CPHA' followed by the currently configured clock phase value.
This function sets the number of bits per transmission. The SPI bus can be configured to either 8 or 16 bits per transfer. The default setting is 8 bits per transfer.
This function takes two parameters:
spiIndex, which is always 0 on Binho Nova host adapter.
bits, which is the number of bits per transfer and can be either 8 or 16.
The host adapter will respond with '-OK' upon successful execution of the command.
This function gets the number of bits per transmission.
This function takes one parameter:
spiIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'SPI0' followed by 'TXBITS' followed by the currently configured number of bits per transfer.
This function starts the SPI Controller. This command must be issued before sending/receiving any data on the SPI bus.
This function takes one parameter:
spiIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command.
This function is used to send and receive data on the SPI bus.
Before sending the TXRX command, be sure you've selected the target device on your SPI bus. The CS pin of the target device should be driven to the correct logical value using the .
This function takes two parameters:
spiIndex, which is always 0 on Binho Nova host adapter.
bits, which is the number of bits per transfer and can be either 8 or 16.
The host adapter will respond with 'SPI0' followed by 'RXD' followed by the byte of data received from the SPI peripheral device during the transfer.
This function is used to send and receive data on the SPI bus using the buffer.
This function takes two parameters:
spiIndex, which is always 0 on Binho Nova host adapter.
numBytes, which is the number of bytes to transmit from the buffer. Note that this transfer starts from the byte at index 0 in BUF0.
The host adapter will respond with '-OK' upon successful execution of the command.
This function stops the SPI Controller. The command ends the SPI session until a BEGIN command restarts the SPI controller.
This function takes one parameter:
spiIndex, which is always 0 on Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command.
This function performs a SPI transfer up to 1024 bytes in a single transaction. This function minimizes the number of round-trips between the PC and Nova in order to maximize SPI throughput. This function is highly recommended for reading/writing SPI memory devices or in any other application where multibyte transactions are frequently used.
This function takes five parameters:
spiIndex, which is always 0 on Binho Nova host adapter.
writeFlag, which should be 1 if the transaction includes writing data to the SPI bus, or 0 if the transaction is only reading data.
readFlag, which should be 1 if the transaction includes reading data from the SPI bus, or 0 if the transaction is only writing data.
The host adapter will respond with '-OK' upon successful execution of the command when the readFlag is 0. If readFlag is 1, the host adapter will respond with '-SPI0 RXD' followed by the data read from the SPI bus. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
numBytes, which indicates the number of bytes to be transferred on the SPI bus and must match the length of the data parameter.
data, which is a string of hex characters without the leading '0x' and no spaces indicating the data to be written to the bus, and must match the length specified by the numBytes parameter.
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.getClockSPI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.getOrderSPI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.getModeSPI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.getCpolSPI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.getCphaSPI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.setBitsPerTransferSPI(0, 8)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.setBitsPerTransferSPI(0, 8)
binhoDevice.getBitsPerTransferSPI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.setBitsPerTransferSPI(0, 8)
#configure the CS pin
binhoDevice.setIOpinMode(0, 'DOUT')
binhoDevice.setIOpinValue(0, 'HIGH')
binhoDevice.beginSPI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.setBitsPerTransferSPI(0, 8)
#configure the CS pin
binhoDevice.setIOpinMode(0, 'DOUT')
binhoDevice.setIOpinValue(0, 'HIGH')
binhoDevice.beginSPI(0)
binhoDevice.setIOpinValue(0, 'LOW')
binhoDevice.transferSPI(0, 0x9F)
binhoDevice.transferSPI(0, 0x00)
binhoDevice.transferSPI(0, 0x00)
binhoDevice.transferSPI(0, 0x00)
binhoDevice.transferSPI(0, 0x00)
binhoDevice.setIOpinValue(0, 'HIGH')
binhoDevice.endSPI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.setBitsPerTransferSPI(0, 8)
#load the buffer with the data
binhoDevice.clearBuffer(0)
binhoDevice.addByteToBuffer(0, 0x9F)
binhoDevice.addByteToBuffer(0, 0x00)
binhoDevice.addByteToBuffer(0, 0x00)
binhoDevice.addByteToBuffer(0, 0x00)
binhoDevice.addByteToBuffer(0, 0x00)
#configure the CS pin
binhoDevice.setIOpinMode(0, 'DOUT')
binhoDevice.setIOpinValue(0, 'HIGH')
binhoDevice.beginSPI(0)
binhoDevice.setIOpinValue(0, 'LOW')
binhoDevice.transferBufferSPI(0, 5)
binhoDevice.setIOpinValue(0, 'HIGH')
binhoDevice.endSPI(0)
#see what data was received during the transfer
print(binhoDevice.readBuffer(0, 5))from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.setBitsPerTransferSPI(0, 8)
#configure the CS pin
binhoDevice.setIOpinMode(0, 'DOUT')
binhoDevice.setIOpinValue(0, 'HIGH')
binhoDevice.beginSPI(0)
binhoDevice.setIOpinValue(0, 'LOW')
binhoDevice.transferSPI(0, 0x9F)
binhoDevice.setIOpinValue(0, 'HIGH')
binhoDevice.endSPI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
# configure the SPI Bus
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.setBitsPerTransferSPI(0, 8)
hostAdapter.setIOpinValue(0, 'HIGH')
# Assert CS pin
hostAdapter.setIOpinValue(0, 'LOW')
# Read 1024 bytes
print(binhoDevice.writeToReadFromSPI(0, 0, 1, 1024, 0))
# DeAssert CS pin
hostAdapter.setIOpinValue(0, 'HIGH')
hostAdapter.setIOpinValue(0, 'LOW')
# Write 4 bytes and then read 4 bytes (8 total bytes)
print(binhoDevice.writeToReadFromSPI(0, 1, 1, 8, 'DEADBEEF00000000'))
hostAdapter.setIOpinValue(0, 'HIGH')We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
The function starts the Atmel SWI host on the given IO pin. The SWI protocol can be used on any of the IO pins, however it is especially convenient to use it on IO0 and IO2 as the internal pull-up resistor can be used thus eliminating the need for an external pull-up resistor.
This function takes three parameters:
swiIndex, which is always 0 on the Binho Nova host adapter.
pin, which can be any of the IO pins 0 through 4.
pullup, which can be either True or
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function is used to send either a WAKE, ONE, or ZERO token, as defined by the Atmel SWI protocol specification. Note that due to the timing constraints of the protocol, the delay between communication with the host adapter and the PC may prohibit the construction of full data packets by stringing together a series of ZERO and ONE tokens with this command. For actual data packet transmission, use the PACKET command.
This function takes two parameters:
swiIndex, which is always 0 on the Binho Nova host adapter.
token, which can be WAKE, ZERO, or ONE.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function transmits a flag as defined by the Atmel SWI protocol. Note that this command is simply using the TX command below to send the predefined byte value of each of the four flags.
This function takes two parameters:
swiIndex, which is always 0 on the Binho Nova host adapter.
flag, which can be COMMAND, TRANSMIT, IDLE, or SLEEP.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function transmits a COMMAND flag.
This function takes one parameter:
swiIndex, which is always 0 on the Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function transmits a TRANSMIT flag.
This function takes one parameter:
swiIndex, which is always 0 on the Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function transmits an IDLE flag.
This function takes one parameter:
swiIndex, which is always 0 on the Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function transmits a SLEEP flag.
This function takes one parameter:
swiIndex, which is always 0 on the Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function transmits a byte of data as defined by the Atmel SWI protocol.
This function takes two parameters:
swiIndex, which is always 0 on the Binho Nova host adapter.
data, which is the byte of data to be transmitted.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function receives n bytes of data as defined by the Atmel SWI protocol.
This function takes two parameters:
swiIndex, which is always 0 on the Binho Nova host adapter.
data, which is the byte of data to be transmitted.
The host adapter will respond with 'SWI0' followed by 'RXD' followed by n bytes of received data.
This function is used to set the opcode of an SWI packet.
This function takes two parameters:
swiIndex, which is always 0 on the Binho Nova host adapter.
opCode, which is the byte of data to be transmitted.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function is used to set the value of the Param1 byte of the SWI Packet.
This function takes two parameters:
swiIndex, which is always 0 on the Binho Nova host adapter.
value, which is the byte of data to be transmitted in the Param1 field of the packet.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function is used to set the 16bit value of the Param2 field of the SWI Packet.
This function takes two parameters:
swiIndex, which is always 0 on the Binho Nova host adapter.
data, which is the 16bit value to be transmitted in the Param2 field of the packet.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function is used to set the bytes of the Data field one by one.
This function takes three parameters:
swiIndex, which is always 0 on the Binho Nova host adapter.
index, which is the byte index to load the value into the Data field.
value, which is the byte of data loaded into the given index of the Data field.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function is used to set the Data field of the SWI packet to the contents from a buffer.
This function takes three parameters:
swiIndex, which is always 0 on the Binho Nova host adapter.
byteCount, which is the number of bytes to load from the buffer.
bufferName, which is the name of the buffer to use, typically BUF0.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function sends the the constructed SWI packet.
This function takes one parameter:
swiIndex, which is always 0 on the Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
This function clears the OpCode, Param1, Param2, and Data fields of the SWI Packet.
This function takes one parameter:
swiIndex, which is always 0 on the Binho Nova host adapter.
The host adapter will respond with '-OK' upon successful execution of the command. In case of an invalid parameter, the host adapter will respond with '-NG' indicating the command did not execute successfully.
Falsepinfrom binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.sendFlagSWI(0, 'IDLE')from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.sendCommandFlagSWI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.sendTransmitFlagSWI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.sendIdleFlagSWI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.sendSleepFlagSWI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.transmitByteSWI(0, 0xAA)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
print(binhoDevice.receiveBytesSWI(0, 5))
#-SWI0 RXD 0x0A 0x0B 0x0C 0x0D 0x0Efrom binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.setPacketOpCodeSWI(0, 0x02)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.setPacketOpCodeSWI(0, 0x02)
binhoDevice.setPacketParam1SWI(0, 0x00)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.setPacketOpCodeSWI(0, 0x02)
binhoDevice.setPacketParam1SWI(0, 0x00)
binhoDevice.setPacketParam2SWI(0, 0x0003)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.setPacketOpCodeSWI(0, 0x02)
binhoDevice.setPacketParam1SWI(0, 0x00)
binhoDevice.setPacketParam2SWI(0, 0x0003)
binhoDevice.setPacketDataSWI(0, 0, 0x00)
binhoDevice.setPacketDataSWI(0, 1, 0x11)
binhoDevice.setPacketDataSWI(0, 2, 0x22)
binhoDevice.setPacketDataSWI(0, 3, 0x33)
binhoDevice.setPacketDataSWI(0, 4, 0x44)
binhoDevice.setPacketDataSWI(0, 5, 0x55)
binhoDevice.setPacketDataSWI(0, 6, 0x66)
binhoDevice.setPacketDataSWI(0, 7, 0x77)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.setPacketOpCodeSWI(0, 0x02)
binhoDevice.setPacketParam1SWI(0, 0x00)
binhoDevice.setPacketParam2SWI(0, 0x0003)
data = [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF]
binhoDevice.writeToBuffer(0, 0, data)
binhoDevice.setPacketDataFromBufferSWI(swiIndex, 32, 'BUF0')
binhoDevice.sendPacketSWI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.setPacketOpCodeSWI(0, 0x02)
binhoDevice.setPacketParam1SWI(0, 0x00)
binhoDevice.setPacketParam2SWI(0, 0x0003)
binhoDevice.setPacketDataSWI(0, 0, 0x00)
binhoDevice.setPacketDataSWI(0, 1, 0x11)
binhoDevice.setPacketDataSWI(0, 2, 0x22)
binhoDevice.setPacketDataSWI(0, 3, 0x33)
binhoDevice.setPacketDataSWI(0, 4, 0x44)
binhoDevice.setPacketDataSWI(0, 5, 0x55)
binhoDevice.setPacketDataSWI(0, 6, 0x66)
binhoDevice.setPacketDataSWI(0, 7, 0x77)
binhoDevice.sendPacketSWI(0)from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SWI')
binhoDevice.beginSWI(0, 0, True)
binhoDevice.sendTokenSWI(0, 'WAKE')
binhoDevice.setPacketOpCodeSWI(0, 0x02)
binhoDevice.setPacketParam1SWI(0, 0x00)
binhoDevice.setPacketParam2SWI(0, 0x0003)
binhoDevice.setPacketDataSWI(0, 0, 0x00)
binhoDevice.setPacketDataSWI(0, 1, 0x11)
binhoDevice.setPacketDataSWI(0, 2, 0x22)
binhoDevice.setPacketDataSWI(0, 3, 0x33)
binhoDevice.setPacketDataSWI(0, 4, 0x44)
binhoDevice.setPacketDataSWI(0, 5, 0x55)
binhoDevice.setPacketDataSWI(0, 6, 0x66)
binhoDevice.setPacketDataSWI(0, 7, 0x77)
binhoDevice.sendPacketSWI(0)
binhoDevice.clearPacketSWI(0)Thanks to incredible feedback and support from our customers, we've released an entirely rebuilt python library for Binho Nova. While we'll continue to support our previous library, active development will only take place on this one.
Aside from taking a more pythonic approach to implementing the library, we've also introduced a lot of structure and abstraction to make it even easier to use your Nova, including a command line interface and interactive shell. We've also baked numerous example scripts right into the library for easy reference.
The easiest way to get started is to install this library using pip:
Using Nova in your scripts is as simple as importing the library:
Then initialize a connection to the binho device as such:
When working on setups with multiple devices, you can specify the device to connect to in the following 3 ways:
grab the device with a specific index
binho = binhoHostAdapter(index=0)
or get the device using the COM port
binho = binhoHostAdapter(port=targetComport)
or get the device using the deviceID number
binho = binhoHostAdapter(deviceID = targetDeviceID)
At this point it's possible to control the device as desired. Examples of common use cases are included in this library and are briefly discussed below. When you're done with the device, be sure to close out the connection with the following:
That's all there is to it. The example scripts are introduced below, but it may also make sense to review the new Command line interface as well, as it may be possible to achieve your goals without writing any code at all.
Take a look in the folder of the codebase (hosted on github) to see example scripts which demonstrate how to use this library in your own scripts to automate Nova. These example scripts feature a lot of commentary and serve as a tutorial for using this library.
Basic Examples:
This example shows the basics of establishing a connection with device and setting it's LED to BLUE. It's a boring example, but introduces the typical script structure and basics of working with this library.
This example shows how to use IO pins for digital input and output, as well as configuring hardware PWM.
This example shows how to use IO pins for analog input (using the ADC) and output (using the DAC).
Advanced Examples:
- Reading and Writing common EEPROM devices has never been easier. Also shows how to read to / write from, and verify against .bin and .hex files.
- Reading and Writing common FLASH devices has never been easier using our SPI
- Discover the parameters of a SPI Flash device without any prior knowledge by reading the JEDEC ID and SPI Flash Discoverable Parameters.
he installation of this library also includes the new command line interface which makes it possible to perform a lot of common functions without needing to write any code. The format of the commands is as follows:
Each command has their own unique arguments, but all commands except 'info' support the following:
-h, --help: prints the list of arguments
-v, --verbose: display more details on the console during execution
-d, --device <deviceID>: connect to the device with the provided deviceID number
Note that only one of -d, -p, or -i arguments can be supplied to any command.
Device Management Subcommands
binho info This command can be used to find all Novas connected to the PC and get their associated information such as serial number, COM port, and firmware version. It will also indicate if a device is in DAPLink or Bootloader mode as well.
binho dfu This command can be used to automatically update device firmware or just enter Bootloader mode.
IO Subcommands
binho gpio
This command can be used to take digital readings or drive IO pins as digital outputs. Note that the device does not retain it's state between consecutive runs of this command. As such, a subsequent run will overwrite any previous pin configurations.
binho dac This command can be used to set the DAC output to a given voltage or raw 10bit value.
Protocol Subcommands
binho i2c
This command can be used to perform I2C Scans, Reads, and Writes.
binho eeprom
This command can be used to read from and write to common I2C EEPROM devices.
binho spi
This command can be used to perform SPI transfers.
DAPLink Subcommands
Binho Nova can be used to program and debug microcontrollers by operating in DAPLink mode.
binho daplink
Use this command to switch Nova into and out of DAPLink mode.
binho flasher
While in DAPLink mode, this command can be used to program bin/hex files into microcontrollers.
Misc. Subcommands
binho shell
This command can be used to open up a connection to the device and begin an interactive shell.
binho custom
Adding custom commands is very easy! This command is just meant as a template which can be used to create your own commands to extend the command line functionality for any specific tasks. You can see the implementation .
We welcome contributions to our library, and we've made it easy. Here's some brief guidance to get started developing with the library.
We're planning to use ReadTheDocs to host detailed library documentation in the near future. You can build the documentation with the following command.
We're looking forward to adding support for various common UART use-cases. Additionally, we'll be adding in support for Atmel SWI if we find enough folks interested in that protocol. Our development roadmap is highly determined by customer requests and feedback, so please feel free to reach out if there's a particular feature you'd like to see added into this library.
The release can be viewed on PyPi here:
And here's another direct link to the our public repo on Github:
pip install binhoSPI Communication This example shows how to configure the device for SPI communication and transfer data. This example can be run by connecting SDI and SDO signals to loopback the data.
I2C Communication This example demonstrates how to configure the device for I2C communication and perform reads and writes. It also shows how to scan the bus, and perform read register and write register commands. This example is easily adaptable to work with any I2C device you have available.
1Wire Communication This example demonstrates how to configure the device for (Dallas / Maxim) 1Wire communication by writing to and reading from a DS24B33+ 1Wire EEPROM. Note that the command set for most 1Wire EEPROMs is very similar so this example may work with other devices too.
-p, --port <commport>: connect to the device on the provided COM port
-i, --index <i>: connect to the device at index i
binho pwm
This command can be used to configure the IO pins to be used as PWM outputs.
binho spiflash [Coming Soon!]
This command can be used to read from and write to common SPI Flash devices.
binho 1wire This command can be used to communicate with 1Wire devices.
import binho# grab the first device found the system finds
binho = binhoHostAdapter()binho.close()binho <<subcommand>> [arguments]python3 setup.py installpip3 install .[dev]
docs\make.bat html