HammingSerial-master

所属分类:其他
开发工具:C/C++
文件大小:8KB
下载次数:0
上传日期:2020-11-10 18:47:33
上 传 者asdadsadasd
说明:  hamming encoding example for arduino uno library

文件列表:
FifoBuffer.h (1209, 2018-05-09)
FifoBuffer_Tests.h (1938, 2018-05-09)
Hamming.h (6827, 2018-05-09)
Hamming.ino (294, 2018-05-09)
HammingSerial.h (5433, 2018-05-09)
HammingSerial_Tests.h (2084, 2018-05-09)
Hamming_Tests.h (4259, 2018-05-09)
Test_Framework.h (373, 2018-05-09)

# HammingSerial A Hamming(7,4) encoded serial port with a 16 byte packet size. Includes a Hamming Encoder/Decoder and Fifo Buffer. HammingCode class: (Implements Hamming(7,4) error correction protocol. Look it up in Wikipedia.) serialInversion - Set to true to invert the 3rd and 7th bit. This makes the bit stream suitable for devices that have trouble with more than 4 consecutive bits. Both sender and receiver must have the same setting. parityBit - When parity bit is true, the encoder can detect a 2 bit error and correct a one bit error (at the cost of an extra bit). When false, it can detect and correct a one bit error only. errorCorrected - decode() sets this to true if it corrects an error, false otherwise. Used to see if errors are being corrected. enocde() - encodes in into out. If parity is false then out[] contains 7 bit data (the 8th bit is a parity bit) decode() - decodes in into out. Returns true if the conversion was a success, false otherwise. fastEncode() - same as encode() but uses a lookup table, which is significantly faster. Encode() is retained for interest sake. FifoBuffer class: (First In, First Out Buffer) count - The number of bytes in the buffer. Max size is FIFO_BUFFER_SIZE. isFull() - Returns true if the buffer is full push() - adds a byte to the end of the buffer and returns true if successful. peek() - Takes the first byte in the buffer and stores it in value but does not remove it from the buffer. Returns true if successful. pop() - Takes the first byte in the buffer and stores it in value, removing it from the buffer. Returns true if successful. clear() - Clears the buffer. HammingSerial class: (Implements an Hamming Encode Serial Port with 8 bit CRC error detection and packetization) To send a packet, push() the data onto the tx_buffer and then call send() To receive packets, call receive(). If the result is true then rx_buffer contains a complete packet. Somewhere in the main program loop, you need to call event(), which flushes the tx_buffer. HammingSerial(serial) - Pass a HardwareSerial object to the constructor to tell it which Arduino serial port to use. rx_buffer - A FifoBuffer which recieves a decoded packet tx_buffer - A FifoBuffer to assemble a packet for encoding and sending receive() - reads data from the serial port, decodes it, and places the data in rx_buffer. Returns true when a complete packet exists in the buffer. send() - Encodes the data in tx_buffer and sends it out on the serial port. event() - Must be called in program loop to ensure data is transmitted on the serial port.

近期下载者

相关文件


收藏者