Comments (6)
That is strange. What is the output?
I added this method to the tests and it passes...:
def test_send_sysex_string(self):
self.board.send_sysex(0x79, ["test"])
sysex = (chr(0xF0), chr(0x79), 't', 'e', 's', 't', chr(0xF7))
self.assert_serial(*sysex)
from pyfirmata.
I have tried the same code as @sunfffd and I'm also getting corrupt characters on my display.
@tino I have looked at your test and you are sending "0x79" to Firmata which is a firmware query.
"0x71" is the code for sending strings. I don't understand how your test can be accurate.
from pyfirmata.
I looked at the Firmata docs http://firmata.org/wiki/Protocol and according to the protocol spec, a string message must be 14-bits per char.
In pyfirmata.py, in the "send_sysex()" function, data is being send as 7-bits.
'Sysex data can be 7-bit bytes only. Consider using utils.to_two_bytes for bigger bytes.'
It seems like that could be the issues but I'm too noob with python to figure out how to use the "utils.to_two_bytes" function.
from pyfirmata.
I were able to figure it out :)
The chars need to be of 14-bits per char.
This can be send as per follows:
board.send_sysex(0x71, util.str_to_two_byte_iter("test message\0"))
If would be very nice if pyfirmata could do that for us.
def send_sysex(self, sysex_cmd, data=[]):
"""
Sends a SysEx msg.
:arg sysex_cmd: A sysex command byte
:arg data: A list of 7-bit bytes of arbitrary data (bytes may be
already converted to chr's)
"""
#Convert strings to 14-bit chars. Also add a null terminator.
if sysex_cmd == 0x71:
data = str_to_two_byte_iter(data+"\0")
self.sp.write(chr(START_SYSEX))
self.sp.write(chr(sysex_cmd))
for byte in data:
try:
byte = chr(byte)
except TypeError:
pass # byte is already a chr
except ValueError:
raise ValueError('Sysex data can be 7-bit bytes only. '
'Consider using utils.to_two_bytes for bigger bytes.')
self.sp.write(byte)
self.sp.write(chr(END_SYSEX))
Then we only need to call this:
self.board.send_sysex(0x71,"test")
This works fine and the string comes through as expected.
from pyfirmata.
Is this still a problem now that we are using byte arrays?
from pyfirmata.
Closing, as I can't move forward with this. Hopefully it's not a problem anymore!
from pyfirmata.
Related Issues (20)
- HC-SR04 or PulseIN
- Problem with the method ping()
- Does it have any kind of unit testing?
- problem in running a RGB Led with pyfirmata
- Why does the pyfirmata closes after a certain amount of time running?
- Steps for PWM in pyfirmata
- How to get 20kg servo working in pyfirmata HOT 2
- documentation enhancement request: How to use a newly defined board layout dict?
- python 3.10.5 HOT 1
- Save data with analog read
- ImportError HOT 2
- inspect.getargs - Not available in Py 3.11 - Replace with inspect.getfullargspec HOT 6
- Error obtaining data when multiple sensors at the same time are used on a ArduinoUno
- AttributeError
- (python 3.x) ImportError: no know parent package
- Import "pyfirmata" could not be resolved
- Sending text to display no longer working? < board.send_sysex( STRING_DATA, util.str_to_two_byte_iter( text ) ) > HOT 1
- Communicating with I2C module
- Pyfirmata not working but there are no errors HOT 1
- shiftOut command missing HOT 1
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 pyfirmata.