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

writer doesn't write anything #79

Open
anormalrobot opened this issue Feb 5, 2022 · 3 comments
Open

writer doesn't write anything #79

anormalrobot opened this issue Feb 5, 2022 · 3 comments

Comments

@anormalrobot
Copy link

anormalrobot commented Feb 5, 2022

Hello,

When i was trying to send a data with following code nothing happens:

from asyncio import get_event_loop
from serial_asyncio import open_serial_connection

async def run():
reader, writer = await open_serial_connection(url='/dev/ttyUSB1', baudrate=115200)
writer.write(b'Hello World')

loop = get_event_loop()
loop.run_until_complete(run())

But when i want to read and write everything works perfectly. Is there any way to write only async serial.

Have a great day :)

@nlhnt
Copy link

nlhnt commented Oct 13, 2022

How do you now that nothing happens?
The message is send to /dev/ttyUSB1 and should the device do something when it receives b'Hello World'?
Is there some physical response or lack of that?

@anormalrobot
Copy link
Author

I had an arduino connected on /dev/ttyUSB1 and if it receives any data (if(Serial.available()>0)) it has to blink. So nothing blinks.
I solved problem with write than read structure. But still nothing works with only write structure.

@katomaso
Copy link

Your data are most likely stuck in the write buffer. What you did was to append your data to a write buffer and then immediately ended the loop. This would call _connection_lost and clear the write buffer. The solution should be

async def run():
    reader, writer = await open_serial_connection(url='/dev/ttyUSB1', baudrate=115200)
    writer.write(b'Hello World')
    writer.close()

loop = get_event_loop()
loop.run_until_complete(run())

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