1

I'd like to read data (from a device connected to the serial port) in QGIS using Python. Its not a GPS device; it is an AIS receiver so the QgsGPS tools obviously won't work.

I have got as far as;

QgsGPSDetector.availablePorts()

Which does appear to recognise the device;

[(u'localhost:2947:', u'local gpsd'), (u'\\\\.\\COM11', u'COM11:')]

I understand that serial/pyserial library is not included in the PyQGIS environment. If it was I think I could figure it out easily.

Any suggestions how to write a short script to read raw data from the serial/COM ports?

1 Answer 1

2

I fixed my issue in the following manner:

Installed pyserial at the Command Line using:

pip install serial 

Once I verified the package was successfully installed (by running a Python session and typing 'import serial') I then had to ensure the package was installed in the Pycharm project interpreter. This is done manually in Pycharm as follows:

Pycharm>File>Settings>Project>Project Interpreter>

Scroll down the list of packages and double click serial. Then in the next window simply click "install package". I followed this up with a reboot and it worked fine since then. Note: This worked for QGIS v3.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.