Skip to content
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

Certain Marlin commands don't work #3

Open
d3v-null opened this issue Aug 14, 2017 · 1 comment
Open

Certain Marlin commands don't work #3

d3v-null opened this issue Aug 14, 2017 · 1 comment

Comments

@d3v-null
Copy link

d3v-null commented Aug 14, 2017

Hi,
since the uArm firmware is based on Marlin, but has implemented its own way of numbering commands, any Marlin commands that do not have this feature enabled will not work with this python library, even though they work when sent directly.

e.g. if I call send_cmd_sync('M105'), the python library will append #N and expect $N in return, but since it's a Marlin command, it only return ok T:23.3 /0.0 @:0 which means that the library will think that the firmware never actually responded.

I could solve this by modifying packed_in_cb in protocol_ascii.py like so, but it only works if there are no other commands pending.

    def packet_in_cb(self, msg):
        #print('{}: <- '.format(self.node) + msg)
        if len(msg) < 2:
            return
        if msg[0:1] == '@':
            if self.ports['report']['handle']:
                self.logger.log(logging.VERBOSE, 'report: ' + msg)
                self.ports['report']['handle'].publish(msg[1:])
        elif msg[0:1] == '$':
            index = msg.find(' ')
            index = index if index != -1 else len(msg)
            cnt = int(msg[1:index])
            if cnt in self.cmd_pend.keys():
                # TODO: avoid KeyError
                self.cmd_pend[cnt].finish(msg[index + 1:])
            else:
                pass # warning...
        elif msg[0:2] == 'ok' and len(self.cmd_pend) == 1:
            cnt = list(self.cmd_pend)[0]
            self.cmd_pend[cnt].finish(msg)

Let me know if you would like me to submit a PR.

@dukelec
Copy link

dukelec commented Aug 16, 2017

This should be fixed in the firmware: always return $N if get #N.

Thank you for pointing this out, I will let you know when it getting fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants