-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error trying to connect to Stepper using python #2
Comments
================ EXAMPLE PYTHON CODE - Use chunks as needed ================For full documentation see https://www.wifistepper.com/interfacesimport goodrobotics as gr host = "192.168.1.107" Create motor objectMOTOR = gr.WifiStepper(host=host) MOTOR = gr.WifiStepper(proto=gr.ComCrypto, host=host, key="<AUTH_KEY>") # For crypto authConnect (will throw exception on failure)MOTOR.connect() Write motor configurationMOTOR.setconfig({ Read configurationconfig = MOTOR.getconfig() config is a dict() of configuration mapSend speed commandrpm = gr.RPM() Emergency stop motorMOTOR.estop() Read statusstate = MOTOR.getstate() state is a dict() with keys: busy, stepss, hiz, vin, pos, mark, dir, movement, stepclock, switch,flags=dict( switch, commanderror, overcurrent, undervoltage, thermalwarning,thermalshutdown, stalldetect ) |
this is the function that seems to be throwing the error. self.sock.send(self._preamble(self._TYPE_STD) + self._header(opcode, subcode, target, queue, packetid, len(data)) + data) return packetid is this an issue connecting, or possible issue with the "data" variable string type? |
I can issue commands with curl without issues: C:\code\WifiStepper>curl -sS "http://192.168.1.107/api/motor/run?dir=forward&stepss=100" |
Ah, this must be an issue with python 3.7 not auto-converting between bytes and strings. |
@aklofas Yes, that's exactly it - the code does not work on Python 3. The pull request I have linked fixes it, while maintaining Python 2 compatibility. |
New install. I configured the WS to use station wireless, and verified I can connect through the website and run commands on my nema 17 stepper.
Having problems running python commands. Using python 3.7, and imported the library in the directory.
Also changed the host name using IP in the py code.
C:\code\WifiStepper2>python ws.py
Traceback (most recent call last):
File "ws.py", line 12, in
MOTOR.connect()
File "C:\code\WifiStepper2\goodrobotics.py", line 452, in connect
return self.__comm.connect()
File "C:\code\WifiStepper2\goodrobotics.py", line 211, in connect
return self.cmd_ping(0, 0)
File "C:\code\WifiStepper2\goodrobotics.py", line 228, in cmd_ping
return self._waitreply(self._send(self._OPCODE_PING, self._SUBCODE_CMD, target, queue), self._SUBCODE_ACK)
File "C:\code\WifiStepper2\goodrobotics.py", line 367, in _send
self.sock.send(self._preamble(self._TYPE_STD) + self._header(opcode, subcode, target, queue, packetid, len(data)) + data)
TypeError: can't concat str to bytes
C:\code\WifiStepper2>python --version
Python 3.7.0
The text was updated successfully, but these errors were encountered: