Environment
Windows Subsystem for Linux
with Serial Communication to a GPS.Adafruit GPS connected to a Arduino Nano which is connected to
COM10
. InWindows Subsystem for Linux
this is equivalent to/dev/ttyS10
Requirements:
pyserial
I have written a simple script to read information from the GPS module:
import serial
def select_sentence():
""" This function sends serial data to the GPS module to display only GPGGA and GPRMC"""
def read_gps():
ser = serial.Serial("/dev/ttyS10", 9600)
while True:
print(ser.readline().decode('utf-8'))
if __name__ == "__main__":
select_sentence()
read_gps()
In the virtualenv I chose Python3
and when I executed it I got Permission Error
for the serial port /ttyS10
so I chose to sudo chmod 666 /dev/ttyS10
to use the script in the virtualenv
.
However is there an alternative to the above mentioned chmod /dev/serial
in order to avoid the PermissionErrors
?
I am aware that even in the virtualenv
when one uses sudo
the packages installed in the virtualenv are no considered and instead sudo looks for your global pip
packages.