Ok guys,
I'm gonna try to give you a full explanation.
I thought it would be a great idea to keep it open during the application life
time for one reason.
My webserver (running on windows) got a Velleman VM8090 module plugged in with
a usb cable, my serial port is virtual.
Working process :
1) A QR code is read by a QR code reader
2) The QR code is paste into an input field and send to a controller
3) The controller checks the validity of the code in agreement with a
database
4) If the code is approuved the controller use shell_exec to open a python
command line
5) A python script is call with args like this :
Python C:\temp\gate.py on
6) Every time the script is launch, it open the serial port, send the
command depending on the argument and close it.
7) Sometimes, the script return < The Serial port is already open >, and a
delay is identified. Below the function that open the port :
def open_device() :
try:
print("Opening serial port")
ser = serial.Serial(
port='COM200',
baudrate=19200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
)
except IOError:
print("Serial port already open !")
ser.close()
ser.open()
return ser
8) Because of this delay I was just thinking about keeping the serial port
open while the application is running.
What do you guys think ? $
Best wishes !
Yann Schoeni
_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32