Documentation for the Code

Faraday Module

class faradayio.faraday.Faraday(serialPort=None)[source]

A class that enables transfer of data between computer and Faraday

_serialPort

serial instance – Pyserial serial port instance.

receive(length)[source]

Reads in data from a serial port (length bytes), decodes slip

A generator function which reads the serial port opened with the instance of Faraday used to read() and then uses the SlipLib module to convert the SLIP format into bytes. Each message received is added to a receive buffer in SlipLib which is then yielded.

Parameters:length (int) – Length to receive with serialPort.read(length)
Yields:bytes – The next message in the receive buffer
send(msg)[source]

Converts data to slip format then sends over serial port

Uses the SlipLib module to convert the message data into SLIP format. The message is then sent over the serial port opened with the instance of the Faraday class used when invoking send().

Parameters:msg (bytes) – Bytes format message to send over serial port.
Returns:Number of bytes transmitted over the serial port.
Return type:int