Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial #584

Open
ajh123 opened this issue Feb 5, 2021 · 9 comments
Open

Serial #584

ajh123 opened this issue Feb 5, 2021 · 9 comments

Comments

@ajh123
Copy link

ajh123 commented Feb 5, 2021

Is there a way to receive data from the serial debugger

@ajh123
Copy link
Author

ajh123 commented Feb 5, 2021

because we can send data blit::debug("Hello, world!");

@Daft-Freak
Copy link
Collaborator

The other direction is mostly used to send commands to the firmware, but if you prefix with 32BLUSER + uint16 length, you can receive data using the "multiplayer" blit::message_received callback.

@ajh123
Copy link
Author

ajh123 commented Feb 5, 2021

Thank you!

@ajh123
Copy link
Author

ajh123 commented Feb 5, 2021

Whats the baud rate to connect via Python would 9600 be fine?

@ajh123
Copy link
Author

ajh123 commented Feb 5, 2021

i tried. this python

import serial
from time import sleep
ser = serial.Serial('/dev/tty.usbmodem3271357530391', 2000000, timeout=2, xonxoff=False, rtscts=False, dsrdtr=False) 
ser.flushInput()
ser.flushOutput()
while True:
  data_raw = ser.readline()
  print(data_raw)
  msg = 'Hello?'
  ser.write(bytes('32BLUSER'+str(len(msg))+msg, 'ascii'))

but the 32blit dose not seem to receive 'Hello?', however the python can receive it's messages

@Daft-Freak
Copy link
Collaborator

The length is a uint16, so you want something like ser.write(b'32BLUSER'+ struct.pack('<H', len(msg)) + msg.encode('ascii')).

Baud rate doesn't matter (but I guess you worked that out already 😄)

@ajh123
Copy link
Author

ajh123 commented Feb 5, 2021

where do i import struct. from im in Python3

@ajh123
Copy link
Author

ajh123 commented Feb 5, 2021

found it, it works now, thanks!

@Gadgetoid
Copy link
Contributor

I wonder if this - receiving debug output and sending arbitrary data back - should be a feature of the tools. You could then just import the relevant part of the tools in your code and do something like (very pseudocode here) ttblit.serial.user("message")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants