pySerialTransfer | Python package to transfer data | Wrapper library
kandi X-RAY | pySerialTransfer Summary
kandi X-RAY | pySerialTransfer Summary
Python package to transfer data in a fast, reliable, and packetized form. If using this package to communicate with Arduinos, see for the corresponding and compatible library (also available through the Arduino IDE's Libraries Manager).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Process rx object
- Create a transaction object
- Writes a struct object to buffer
- Send a message to the server
- Calculate the CRC for the given array
- Calculate the overhead of the transaction
- Open serial connection
- Check the status of the packet
- Returns the number of bytes available
- Unpack a packet
- Calculate the CRC for an array
- Return a list of all serial ports
- Close the connection
- List of serial ports
- Print the cs table
- Convert value to lsb
- Return byte value at position pos
- Convert val to bytes
- Return the number of bytes in a value
pySerialTransfer Key Features
pySerialTransfer Examples and Code Snippets
import time
from pySerialTransfer import pySerialTransfer as txfer
if __name__ == '__main__':
try:
link = txfer.SerialTransfer('COM17')
link.open()
time.sleep(2) # allow some time for the Arduino to completely r
import time
from pySerialTransfer import pySerialTransfer as txfer
def hi():
'''
Callback function that will automatically be called by link.tick() whenever
a packet with ID of 0 is successfully parsed.
'''
print("hi")
#include "SerialTransfer.h"
SerialTransfer myTransfer;
void setup()
{
Serial.begin(115200);
myTransfer.begin(Serial);
}
void loop()
{
if(myTransfer.available())
{
// send all received data back to Python
for(uint16_t i=0; i <
Community Discussions
Trending Discussions on pySerialTransfer
QUESTION
I have working code that sends a struct from a Raspberry Pi to an Arduino using pySerialTransfer when the devices are connected via a USB cable. I'd like to do that over bluetooth instead of with a USB cable, however.
Independently, using separate python code and a separate Arduino sketch, I've been able to get the Raspberry Pi & Arduino to communicate over bluetooth via a continuous stream of text or binary data.
My issue is that I don't see how to combine the two approaches - i.e.: if I send a binary-encoded structure over bluetooth, I don't see how I get the benefits of the pySerialTransfer / SerialTransfer libraries to parse it on the receiving end. I see how I can do the parsing "manually", looking for special terminating characters, etc., but I was hoping to avoid the need for that with pySerialTransfer.
Thanks for any pointers / suggestions / examples. All the working code I've been able to construct so far is here.
pySerialTransfer Working Arduino C serial code ...ANSWER
Answered 2020-May-02 at 00:19pySerialTransfer / SerialTransfer will arrange data in packet format with CRC so it fast and safe way to communicate over serial.
In fact, there are no special character to terminate packet because binary data can be any character from 0x00 to 0xFF cover all ASCII code.
QUESTION
I have an Arduino which is communicating properly with my Mac over serial using the pySerialTransfer library, running for hours. Then there is an interruption of the serial of some sort - though I've been unable to identify the cause when this happens overnight, I can reproduce the behavior pretty easily by just unplugging the Arduino USB cable from the laptop. The python code on my laptop continues to run, but gets into this infinite error loop:
...ANSWER
Answered 2020-Apr-25 at 00:53I started down the tack of approaches to kill function calls that run too long, with potential solutions using StopIt and multiprocessing. But those failed because it seems that what was actually happening was that pySerialTransfer was spawning a separate thread to handle the serial communication and then returning control back to the calling function, but keeping that separate thread alive, and that separate thread was the one stuck in infinite error loops. So I couldn't detect the condition by the solutions to terminate long-running function calls. And as mentioned in the comment thread, no exceptions were passed up to the caller either, so try-except clauses also failed.
However, the one thing I could detect was that an error to stderr was logged, and so if I could redirect that and detect a new error there, then that would get me down the right path. Enter this guidance, which steered me towards this solution:
QUESTION
I am trying to communicate bi-directionally between my laptop & my arduino via passing a common struct back and forth, but am having trouble unpacking the bytes returned from the Arduino. Using pySerialTransfer, it seems rxBuff returns a list of numbers that I can't figure out how to convert into a byte-string for struct.unpack to render back into the numbers I started with.
At present, the Arduino code simply receives the data and spits it back, no transformations or action on the Arduino side. Here's my Arduino code:
...ANSWER
Answered 2020-Apr-22 at 18:07Is this what you are looking for:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pySerialTransfer
You can use pySerialTransfer like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page