LogoLogo
Nova Host AdapterAccessoriesDownloadsSupport
  • Customer Support Portal
  • Getting Started
    • Hardware Setup
    • QuickStart with GUI
      • IO in Mission Control
      • SPI in Mission Control
      • I2C in Mission Control
      • UART in Mission Control
    • QuickStart with Python
    • QuickStart with CoolTerm
  • User Guide
    • Product Overview
    • Safety Notice
    • Compliance & Legal
    • System Requirements
    • Using the Device
      • Software Installation
      • Connecting the Hardware
      • Sending Commands
      • Receiving Responses
      • Receiving Interrupts
      • Device Settings
      • Using the Buffer
      • Using IO
      • Using SPI
      • Using I2C
        • I2C Controller
        • I2C Peripheral
      • Using 1-Wire
      • Using SWI
      • Using UART
      • Updating Firmware
    • ASCII Command Set
      • Device Commands
      • Buffer Commands
      • IO Commands
      • SPI Commands
      • I2C Commands
      • 1-WIRE Commands
      • SWI Commands
      • UART Commands
    • Accessories
      • Breadboard Breakout
      • Qwiic Interface Board
      • Feather Interface Board
      • Total Retrofitter
      • Socket Station
  • Python Libraries
    • Binho Python Package
    • Python Wrapper (legacy)
      • binhoHostAdapter
        • Device Functions
        • Buffer Functions
        • IO Functions
        • SPI Functions
        • I2C Functions
        • 1-WIRE Functions
        • SWI Functions
        • UART Functions
      • binhoUtilities
      • Examples
        • I2C EEPROM Reading And Writing
        • I2C Peripheral Mode
        • SPI FRAM Reading And Writing
        • I2C FRAM Reading And Writing
        • 1-Wire Communication
        • SWI with Atmel Crypto ICs
        • UART Bridge with I2C
        • Using Binho with Pytest
        • Replaying Logic Captures
          • Replay SPI
          • Replay I2C
          • Replay UART
  • Mission Control Software
    • Releases
      • V1.1.6 Release
      • V1.1.4 Release
      • V1.1.3 Release
      • V1.1.0 Release
      • V1.0.6 Release
      • V1.0.5 Alpha Release
      • V1.0.0 Alpha Release
    • How-To
      • How To Update Firmware
  • Firmware Releases
    • V0.2.8 - Stable
    • V0.2.7 - Stable
    • V0.2.5 - Stable
    • V0.2.2 - Stable
    • V0.2.1 - Stable
    • V0.2.0 - Stable
    • V0.1.12 - Stable
  • Experimental Features
    • DAPLink Mode
  • Troubleshooting
    • Windows 7 Driver Installation
    • Windows 8 Driver Problems
    • Linux Permissions
    • MacOS Permissions
  • FAQ
    • What protocols are supported?
    • Where can I find the product datasheet?
    • Can multiple devices be used at the same time?
    • Is the ADC calibrated?
    • How can I use my host adapter with a serial console that doesn't support Local Echo?
    • Is the DAC calibrated?
    • Is there a GUI available?
  • Orders & Shipping
    • Place an Order
    • Requesting a Quotation
    • Placing a Purchase Order
    • Shipping Policy
    • International Shipping
    • Tax Exemption
    • Discounts
    • Distributors
  • Returns & Warranty
    • 90-Day Return Policy
    • 2-Year Warranty
  • Contact Us
  • Learn & Grow
    • Dropping Legacy Terminology
    • What is a host adapter?
    • Binho + CircuitPython
    • Binho + Sparkfun Qwiic_Py
Powered by GitBook
On this page
  • clearBuffer(index)
  • addByteToBuffer(index, val)
  • readBuffer(index, numBytes)
  • writeToBuffer(index, startIndex, values)

Was this helpful?

Export as PDF
  1. Python Libraries
  2. Python Wrapper (legacy)
  3. binhoHostAdapter

Buffer Functions

PreviousDevice FunctionsNextIO Functions

Last updated 4 years ago

Was this helpful?

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 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.

clearBuffer(index)

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:

from binhoHostAdapter import binhoHostAdapter

# Change this to match your COMPort
default_commport = "COM22"

binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)

binhoDevice.clearBuffer(0)

addByteToBuffer(index, val)

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:

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)

readBuffer(index, numBytes)

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:

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 255

writeToBuffer(index, startIndex, values)

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)

# 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)

new Python package