drunsinn / pyLSV2

A pure Python3 implementation of the LSV2 protocol
MIT License
64 stars 24 forks source link

How can I read the XYZ position of the spindle #24

Closed sazima closed 2 years ago

sazima commented 2 years ago

I want to read the spindle position of heidenhan cnc, but I can't find function.

drunsinn commented 2 years ago

Currently there isn't a ready made functions to read any position data as I haven't looked into it. I haven't found any documentation, most of the functions have been discovered by trial and error. If I have some time this weekend I will check if I can find something.

Can you check if TNCcmd can somehow read the information you want? If it is available in TNCcmd there is a high chance I might be able to use Wireshark to decode the protocol.

sazima commented 2 years ago

Maybe so, but I'm not sure

        payload = bytearray()
        payload.append(0)
        payload.append(0x16)
        result = self._send_recive_block(CMD.R_RI, RSP.S_RI, payload)

result: [bytearray(b'\x00\x050.0000\x000.0000\x00500.0000\x000.0000\x000.0000\x00X\x00Y\x00Z\x00B\x00C\x00')]

drunsinn commented 2 years ago

Great find! I checkt with TNC 640 and iTNC programming station and both work with the command you found. It was a bit tricky to decode the result but it worked out in the end. The second byte is the number of axes followed by the actual values followed by the axes letters in order. We are missing info about the first byte which is always zero but it dosen't seem to be necessary :-)

The new function returns a dictionary where the keys are the axes letters and the values are the numerical values.

Pull request #27 contains the implementation. If it works for you I will include it in the next release.

BTW: TNCcmd is part to the TNCremo installation, just look in the program directory. I used this tool to capture the network traffic for most of my reverse engineering. Also, could you let me know with which software version you have checkt pyLSV2? I would like to add them to the list in the readme.

drunsinn commented 2 years ago

function is part of release v0.7.4

sazima commented 2 years ago

Test OK in Heidenhain 530

Valteris commented 1 year ago

I used TNC dialog function SYSREAD