You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below is the OutputProtocol example from the documentation. Is there a way to pass to it user data that is configured at instantiation time? E.g. passing to serial_asyncio.create_serial_connection() a user value that will be propagated to the callback functions of OutputProtocol's ?
The difficulty I have is 1) I don't control the instantiation of this object and 2) I am not familiar with *args and **kwargs in case they hold the answer.
I could try to set the value myself in the protocol returned by serial_asyncio.create_serial_connection() but is there a guarantee that it will be called before the first callback is invoked?
import asyncio
import serial_asyncio
class OutputProtocol(asyncio.Protocol):
def connection_made(self, transport):
self.transport = transport
print('port opened', transport)
...
The text was updated successfully, but these errors were encountered:
The docs for pyserial_asyncio.make_serial_connection() include:
Note: protocol_factory can be any kind of callable, not
necessarily a class. For example, if you want to use a pre-created
protocol instance, you can pass lambda: my_protocol.
Below is the OutputProtocol example from the documentation. Is there a way to pass to it user data that is configured at instantiation time? E.g. passing to serial_asyncio.create_serial_connection() a user value that will be propagated to the callback functions of OutputProtocol's ?
The difficulty I have is 1) I don't control the instantiation of this object and 2) I am not familiar with *args and **kwargs in case they hold the answer.
I could try to set the value myself in the protocol returned by serial_asyncio.create_serial_connection() but is there a guarantee that it will be called before the first callback is invoked?
The text was updated successfully, but these errors were encountered: