Re: [python-win32] Python - connexion to serial port

2018-01-15 Thread Tim Roberts
Schoeni, Yann wrote:
>   
>
> 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.
>
>  
>
> 7)  Sometimes, the script return « The Serial port is already
> open », and a *delay is identified*. Below the function that open the
> port : 
>
> 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 ? $
>

There are two possible solutions.

The only time the port should be open is if you are already processing
another request.  No matter what you do, there's always going to be a
delay in that case.  Your problem, then, is to serialize access to the
serial port, to ensure there's only one request at a time.

Your proposed solution is certainly workable.  You could create a
long-running "serial server" that keeps the serial port open and accepts
requests from your web server.  The other solution is to change your
script so that IT keeps retrying until it's able to open the port, with
a short delay between each attempt.  That way, the web server would
always see success.

The delay with the two solutions should be about the same; you're always
going to have to wait for request A to finish before request B starts,
but the second solution would be easier, from where you are now.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Recycle bin deletion date - mixing shell and winshell?

2018-01-15 Thread Durumdara
Dear Members!

Thank you for "real_filename" info!
It is working well!

Best regars
  dd
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Python - connexion to serial port

2018-01-15 Thread Schoeni, Yann
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
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32