I have the current version of python installed and have a py script to access my focuser and get temperature and focuser location and then log it to a file.
I can get this to run all day long from the c prompt in DOS but when I try to run from Sharpcap the script dies as it cannot find the serial module. I have it installed and it works fine outside Sharpcap. I have even added the serial directory to the environment PATH but that does not work either.
Maybe there is a version problem? Don't know maybe you can offer some suggestions.
Thanks
Don
Can't get Sharpcap to see the serial module in py
-
Jean-Francois
- Posts: 859
- Joined: Sun Oct 13, 2019 10:52 am
- Location: Germany
Re: Can't get Sharpcap to see the serial module in py
Hello Don,
It should work. Can you show your script ?
Is it an ASCOM focuser ?
If yes, you do not need to import a "serial " module.
You can use SharpCap directly or with an ASCOM command.
Jean-Francois
It should work. Can you show your script ?
Is it an ASCOM focuser ?
If yes, you do not need to import a "serial " module.
You can use SharpCap directly or with an ASCOM command.
Code: Select all
SharpCap.Focusers.SelectedFocuser.Temperature
SharpCap.Focusers.SelectedFocuser.Position
or
SharpCap.Focusers.SelectedFocuser.AscomFocuser.Temperature
SharpCap.Focusers.SelectedFocuser.AscomFocuser.Position
or with a serial connection ...
clr.AddReference("System.IO.Ports")
from System.IO.Ports import SerialPort
sp = SerialPort()
sp.PortName = "COM3"
sp.BaudRate = 115200
sp.DataBits = 8
sp.DtrEnable = True
sp.ReadTimeout = 500
...
Jean-Francois
Re: Can't get Sharpcap to see the serial module in py
It will die on the first command which is import serial. Says it cannot find it. I use the serial lib to access the com port of the focuser.
It is an ASCOM focuser Optec TCF LSI 2".
This is strange as I have the serial dir in a specific path statement to make sure all will see it. It is also the new version 3x. I will maybe move a copy of the serial dir into the Sharpcap exe directory to see if that helps.
Thanks
It is an ASCOM focuser Optec TCF LSI 2".
This is strange as I have the serial dir in a specific path statement to make sure all will see it. It is also the new version 3x. I will maybe move a copy of the serial dir into the Sharpcap exe directory to see if that helps.
Thanks
-
Jean-Francois
- Posts: 859
- Joined: Sun Oct 13, 2019 10:52 am
- Location: Germany
Re: Can't get Sharpcap to see the serial module in py
Hello,
Can you use the Optec focuser in SharpCap ?
Select it in the "Settings - Hardware" and then connect it in the "Camera Controls" ?
Jean-Francois
Can you use the Optec focuser in SharpCap ?
Select it in the "Settings - Hardware" and then connect it in the "Camera Controls" ?
Jean-Francois
- admin
- Site Admin
- Posts: 17609
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: Can't get Sharpcap to see the serial module in py
Hi,
the normal approach would be to go via the ASCOM driver and let that handle the serial communcations. It's also worth noting that you can only have one thing connecting to a serial port at once, so if you connect via Python then the ASCOM driver will be unable to connect and vice-versa. If you need to get extra data that the ASCOM driver does not usually provide then some ASCOM drivers (not all) provide a side-channel via the CommandBlind/CommandBool/CommandString methods to directly send data to/from the device - check the documentation for the ASCOM driver (or the source code).
If you do need to access the serial port via Python for some reason, then I think you need to try to get the 'pyserial' package - access to 'serial' no longer seems to be part of the standard python library (maybe it was in Python 2.x but not in 3.x?). External packages will only work in SharpCap if they are pure python - the IronPython interpreter in SharpCap cannot load native python packages. You would need to do something like sys.path.append('c:\path\to\pyserial') to tell the interpreter where to find the code.
Another approach is to use the serial port support from the .NET framework which is available via IronPython - you would do something like this
Documentation - https://learn.microsoft.com/en-us/dotne ... et-10.0-pp
cheers,
Robin
the normal approach would be to go via the ASCOM driver and let that handle the serial communcations. It's also worth noting that you can only have one thing connecting to a serial port at once, so if you connect via Python then the ASCOM driver will be unable to connect and vice-versa. If you need to get extra data that the ASCOM driver does not usually provide then some ASCOM drivers (not all) provide a side-channel via the CommandBlind/CommandBool/CommandString methods to directly send data to/from the device - check the documentation for the ASCOM driver (or the source code).
If you do need to access the serial port via Python for some reason, then I think you need to try to get the 'pyserial' package - access to 'serial' no longer seems to be part of the standard python library (maybe it was in Python 2.x but not in 3.x?). External packages will only work in SharpCap if they are pure python - the IronPython interpreter in SharpCap cannot load native python packages. You would need to do something like sys.path.append('c:\path\to\pyserial') to tell the interpreter where to find the code.
Another approach is to use the serial port support from the .NET framework which is available via IronPython - you would do something like this
Code: Select all
clr.AddReference("System.IO.Ports")
from System.IO.Ports import SerialPort
sp = SerialPort("COM1")
# do stuff with serial port
sp.Close()
cheers,
Robin
Re: Can't get Sharpcap to see the serial module in py
Thanks Robin.