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

python 'coroutine' object is not iterable #3

Open
mkeyno opened this issue Sep 8, 2019 · 3 comments
Open

python 'coroutine' object is not iterable #3

mkeyno opened this issue Sep 8, 2019 · 3 comments

Comments

@mkeyno
Copy link

mkeyno commented Sep 8, 2019

hi
I've tried to reproduce your lib in the following way but I've received an exception
I really appreciated your advice

import asyncio
import serial_asyncio

reader= writer=None

async def SerialHandler(loop):
    global reader, writer
    reader, writer = await serial_asyncio.open_serial_connection(url='COM3', baudrate=115200,loop=loop);    print('Reader,Writer created')
    return reader, writer

async def serialSend(f):
    global   writer    
    print("read serialRead")
    while True:
      writer.write(b'SEND DONE\n')
      await asyncio.sleep(1/f);
	  

async def recvCallback():
    global reader 
    while True:
        msg = await reader.readuntil(b'\n')
        print(f'received: {msg.rstrip().decode()}')


def  begin():
    loop = asyncio.get_event_loop()
    reader, writer =  await SerialHandler(loop)
    future = asyncio.run_coroutine_threadsafe(serialSend(50), loop)
    future = asyncio.run_coroutine_threadsafe(recvCallback(), loop)
    #coro = serial_asyncio.create_serial_connection(loop, Output, '/dev/ttyUSB0', baudrate=115200)
    logging.debug("Server ready!");print("Server ready!",ip,port)
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        logging.debug("Shutting Down!");print("Shutting Down!")
        loop.close()

if __name__ == '__main__':
     begin()
@zmitchell
Copy link
Owner

Can you post the entire error message?

@mkeyno
Copy link
Author

mkeyno commented Sep 10, 2019

thanks for responding, its only fire one issue as I put it inside this title
but I think if you could run the code it would reveal the real problem
I've just wanted to use reader, writer, in any place of my code

@zmitchell
Copy link
Owner

I'm very busy at the moment. If you can post the entire error it will give me information about line numbers, etc.

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

2 participants