Hi! I am running PySerial on a raspberry pi 3, and I want to communicate with a board. I have some old code for pyserial that I had written a while ago, and it runs perfectly. Then, I copy and paste it into a new file, and it gives errors.
- Code: Select all | TOGGLE FULL SIZE
import time
import random
from datetime import datetime
import serial
comport = "/dev/ttyACM1"
baudrate = 115200
s = serial.Serial(comport, baudrate)
def update():
days = str(31 - int(datetime.now().strftime('%d')))
hours = str(23 - int(datetime.now().strftime('%H')))
mins = str(59 - int(datetime.now().strftime('%M')))
secs = str(59 - int(datetime.now().strftime('%S')))
print(secs)
out = days+"D "+hours+"H "+mins+"M "+secs+"S"
s.write(out.encode())
while 1:
update()
time.sleep(1)
- Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
File "/home/pi/serial2.py", line 4, in <module>
import serial
File "/home/pi/serial.py", line 6, in <module>
ser = serial.Serial(s_name)
AttributeError: module 'serial' has no attribute 'Serial'