Hi i am new to python i am able to connect to the serial port device & want to know any changes are happened in the device (i want catch the event if any button is press in the device) How can i do this.With The help of pyHook in python i am able to find the keyboard events and mouse events with calling the functions "OnKeyboardEvent" & "OnMouseEvent" how to catch the any serial port device events.Is there any thing in python OnSerailportdeviceEvent function.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
There is no built-in library for using serial ports in Python, you need to use the PySerial library, and then, you just read data from the serial port line by line and see if that line contains data; if it does it means that something changed on your serial device (a button press, for example).
Here's a few links that will help you using that library :
Official PySerial documentation
Blog post that may be useful to you
Question on StackOverflow about PySerial with some helpful answers.