Comments (4)
Can you post your entire Python and Arduino programs along with a description of what your project is supposed to do?
from pyserialtransfer.
Note that the contents of the txBuff should be byte-sized and no larger. If you want to stuff larger values into txBuff, you will have to use a combination of msb(val)
, lsb(val)
, and byte_val(val, pos)
to break down your value's pieces into individual bytes to be then stuffed into the txBuff.
You can also use Python's struct
package to do byte stuffing as well (as found in the Python application Thunder Viewer):
def stuff_float(self, val, start_pos):
'''
Description:
------------
Insert a 32-bit floating point value into the (pySerialTransfer) TX
buffer starting at the specified index
:param val: float - value to be inserted into TX buffer
:param start_pos: int - index of TX buffer where the first byte of
the float is to be stored in
:return start_pos: int - index of the last byte of the float in the TX
buffer + 1
'''
val_bytes = struct.pack('f', val)
self.transfer.txBuff[start_pos] = val_bytes[0]
start_pos += 1
self.transfer.txBuff[start_pos] = val_bytes[1]
start_pos += 1
self.transfer.txBuff[start_pos] = val_bytes[2]
start_pos += 1
self.transfer.txBuff[start_pos] = val_bytes[3]
start_pos += 1
return start_pos
from pyserialtransfer.
Ok thanks I think that answers my question.
from pyserialtransfer.
No problem! Let me know if you still have questions
from pyserialtransfer.
Related Issues (20)
- AttributeError occurs HOT 4
- Examples use double on Arduino side, format 'f' on python side HOT 9
- Arduino tx_data + pySerialTransfer rx_data example fails with esp32 Arduino HOT 6
- Want support for transferring bytes() HOT 1
- Transferring Integers Rather than Float/Double HOT 2
- Problem with the example scripts HOT 7
- Typo in example file and logical error HOT 4
- Error when tryinf to receive integer HOT 1
- Parsing char from Arduino side HOT 6
- Example code error. size mismatch?
- how to use data sent from python in arduion? HOT 1
- How to transmit large array of floats fast and reliably? HOT 2
- Check for CRC error HOT 1
- Sending a Boolean HOT 5
- Is there a maximum variable size for "x" when using myTransfer.sendDatum("x")? HOT 12
- Serial port doesnโt stay connected HOT 2
- Send encoder data HOT 6
- Can we use this library on Raspberry Pi for communication through GPIO? HOT 2
- Are there any examples showing how to save received file to a PC folder. HOT 1
- Data array sometimes gets corrupted if some values are present HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyserialtransfer.