I managed to read the distance value with your code.
Thank you very much for that.
The GLM 50 C can also measure angle/inclination.
I found the command to start the measuring of the angle, but
unfortunately I didn't find the correct command to read the value from the device.
It would be tool, if you could check, if there is a command to read the angle.
#[192, 64, 0, 238], #measure length
#[192, 65, 0, 150], #laser on
#[192, 66, 0, 205], #laser off
#[192, 69, 0, 208], #horn on
#[192, 70, 0, 139], #horn off
#[192, 71, 0, 243], #backlight on
#[192, 72, 0, 177], #backlight off
#[192, 84, 0, 22], #level in mainframe off
#[192, 85, 0, ???],#lock angle on device (first time locked, second call releases the measuring)
#[194, 64, 0, ???],#measure length but with longer received data b'\x00\x044<\x96\x08\x00\x00'
def findCmd2(self):
with open ('cmds' + str(time.time()), 'w') as f:
f.write('start finding command structure\n\n')
#list
addrList = range(192,256) #startbyte: everything greater greater or equal 192 [C0] works
cmdList = range(0,256) #command
cmdData = range(0,1)#range(0,2) #data: found no use so far
#build command
for g in addrList:
for i in cmdList:
for c in cmdData:
checkSumArr = [g, i, 0] #create command used for checksum
checkSumBytes = bytes(checkSumArr) #convert decimal command
k = crc8(checkSumBytes) #calculate checksum
cmdArr = [g,i,c,k] #create full command for device
cmd = bytes(cmdArr) #convert decimal command
#exclude bad commands
#command cause strange beahviour or decive reboot
if ((cmdArr == [192, 53, 0, 166]) or
(cmdArr == [192, 55, 0, 86]) or
(cmdArr == [192, 56, 0, 20]) or
(cmdArr == [192, 54, 0, 46]) or
(cmdArr == [192, 58, 0, 228]) or
(cmdArr == [192, 59, 0, 156]) or
(cmdArr == [192, 60, 0, 82]) or
(cmdArr == [192, 61, 0, 42]) or
(cmdArr == [192, 55, 1, 86]) or
(cmdArr == [192, 55, 1, 240]) or
(cmdArr == [192, 56, 1, 20]) or
(cmdArr == [192, 56, 1, 178]) or
(cmdArr == [192, 53, 1, 0]) or
(cmdArr == [192, 54, 1, 46]) or
(cmdArr == [192, 55, 1, 240]) or
(cmdArr == [192, 54, 1, 136]) or
(cmdArr == [192, 58, 1, 228]) or
(cmdArr == [192, 59, 1, 156]) or
(cmdArr == [192, 60, 1, 82]) or
(cmdArr == [192, 61, 1, 42]) or
(cmdArr == [192, 57, 1, 108]) or
(cmdArr == [192, 57, 1, 202]) or
(cmdArr == [192, 58, 1, 66]) or
(cmdArr == [192, 59, 1, 58]) or
(cmdArr == [192, 60, 1, 244]) or
(cmdArr == [192, 61, 1, 140]) or
(cmdArr == [192, 62, 0, 162]) or
(cmdArr == [192, 62, 1, 4]) or
(cmdArr == [192, 63, 0, 218]) or
(cmdArr == [193, 54, 0, 102]) or
(cmdArr == [192, 57, 0, 108]) or
((i > 50) and (i<60))):
continue
print("cmd:\t ", end='')
print(cmdArr, end='')
f.write("cmd:\t ")
f.write(str(cmdArr))
self.socket.send(cmd)
sleep(0.01) #seems not necessary
data = self.socket.recv(1024)
sleep(0.5) #seems not necessary
if ((self.status[data[0]] is 'ok') or (self.status[data[0]] is 'invalid access level')):
#print('')
print("\tdata:\t", end='')
print(data)
f.write("\tdata:\t")
f.write(str(data))
f.write('\n')
#print(data, end='')
#print("cmd status: ", end='')
#print(self.status[data[0]])
continue
else:
print('')
if (self.status[data[0]] != 'communication timeout'):
print('--> unknown return:\t', end='')
print(data)
f.write('\n')
if self.status[data[0]] is 'unknown command':
print('uC', end='')
if self.status[data[0]] is 'unknown return value2':
print('uC', end='')
if self.status[data[0]] is 'invalid access level':
print('--> invalid access level')
if self.status[data[0]] is 'hardware error':
print('--> hardware error')
if self.status[data[0]] is 'device not ready':
print('--> device not ready')
if self.status[data[0]] is 'communication timeout':
print('--> communication timeout')