I'm using Python 3.8.10. I get the following traceback.
In [1]: from RTk import GPIO
Error: RTk.GPIO not detected.
For more support please visit our website at http://Ryanteck.com/rtk-000-00C
Press enter to close.
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 from RTk import GPIO
File ~/.virtualenvs/RTk_Test/lib/python3.8/site-packages/RTk/GPIO.py:54, in <module>
43 from RTk import adaptors
46 #from os import sys, path
47 #thisdir = path.dirname(path.abspath(__file__))
48 #sys.path.append(thisdir)
(...)
51
52 #Temporarily changing back to normal serial
---> 54 from RTk import rtkserial
56 instance = protocol.GPIOClient(adaptors.SerialAdaptor(rtkserial.s), DEBUG)
58 def setwarnings(option):
File ~/.virtualenvs/RTk_Test/lib/python3.8/site-packages/RTk/rtkserial.py:36, in <module>
34 print ("\nError: RTk.GPIO not detected.\nFor more support please visit our website at http://Ryanteck.com/rtk-000-00C\nPress enter to close.")
35 input()
---> 36 exit()
38 #print ("Debug cable fully detected fine.\n Press enter to launch the terminal.")
41 BAUD = 230400
NameError: name 'exit' is not defined
There are two issues in that traceback.
- Error: RTk.GPIO not detected. This is confusing since it can be confused for either the API path or the hardware.
- The exit() function is not found. This is correct there is NO built-in function named exit(). It's in the
sys package. I doubt this function is even needed since it would only be needed in a script run on the command line. This is a library, not a script. Add an else after the if(rtkGPIOPort == ""): and put everything after that in the else, then removing the exit() will just fall through and do nothing. Then in the RTk/GPIO.py file put a try/except AttributeError block around the instance = protocol.GPIOClient(adaptors.SerialAdaptor(rtkserial.s), DEBUG) statement and put everything else in an else clause.
I also found that there are tabs used in the code which go against PEP8 the Python programming style guide.
I've been developing python code for over 20 years, so I know these are real issues.
I'm using Python 3.8.10. I get the following traceback.
There are two issues in that traceback.
syspackage. I doubt this function is even needed since it would only be needed in a script run on the command line. This is a library, not a script. Add anelseafter theif(rtkGPIOPort == ""):and put everything after that in theelse, then removing the exit() will just fall through and do nothing. Then in theRTk/GPIO.pyfile put atry/except AttributeErrorblock around theinstance = protocol.GPIOClient(adaptors.SerialAdaptor(rtkserial.s), DEBUG)statement and put everything else in anelseclause.I also found that there are tabs used in the code which go against PEP8 the Python programming style guide.
I've been developing python code for over 20 years, so I know these are real issues.