Python Forum

Full Version: New member with simple coding issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All. 

This is my first post here and I am totally new to Python and coding in general. 

I have basically created a simple timing system for use at my work that uses a raspberry pi and a dotstar LED disk. 

Very simply it is triggered by a separate unit that sends out a RF timer signal. When the pi receives this signal it starts a timer and then makes the LED's go a certain colour at a certain time. 

I have also implemented a button connected to one of the pi's pins that 'resets' the programme. (See below)


def restart_program():

        
        lightoff()
        GPIO.output(Xbee, GPIO.LOW)
        os.execv(sys.executable, ['python'] + sys.argv)
        return;
Now the issue I have is that if i leave the code running for a extended period of time and the hit the reset button i get an error and the code stops running. 
The reset works fine if the code hasnt been running long (less than a couple minutes). 
The error i get is:


Error:
Traceback (most recent call last):      File"timer5.py", line 305, in <module>        read_str = ser2.readline()      File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 466, in read       ready,_,_=select.select([self.fd],[],[], self._timeout) ValueError: filedescriptor out of range in select()
Now i have no idea what this means of what the issue is. I assume it is something to do with my serial read. 

Any help would be hugely appreciated. 

Thanks