I am currently trying to create a little python driver to control dobot, however I didn’t succeed to make it work. Could you please try to indicate me where are my errors? Particurlally, I am not sure about data strucure (byte order, units …).
Here is an example of an attemp of sending an order to dobot (position). I get an answer but no reaction at all …
import serial,time import struct def f2b(i):#convert python float into bytes return struct.pack('>f', i)# "<": little-endian, ">": big-endian, both tested unsucessfully ser = serial.Serial(#serial connection port='COM3', baudrate=256000, parity=serial.PARITY_NONE,#serial.PARITY_ODD, stopbits=serial.STOPBITS_ONE,#serial.STOPBITS_TWO, bytesize=serial.EIGHTBITS#serial.SEVENBITS ) ser.isOpen() print "ok" packet=[chr(0xa5),#packet creation f2b(3),#state f2b(0), f2b(3),#X 3cm? f2b(0),#Y f2b(0.2),#Z 0.2mm? f2b(0),#R f2b(0),#grab f2b(1),#MoveMode f2b(0),#griper f2b(0),#pause chr(0x5a)]#chr(90) query = "" for i in packet: query += i print "[",query,"]" ser.write(query) time.sleep(1) out = "" while ser.inWaiting() > 0:#read answer out += ser.read(1) if len(out) == 42: break print "[",out,"]"
Does anybody has an idea about that?