G-Code Driver: How to send Hex-Codes?

302 views
Skip to first unread message

Team14

unread,
Oct 8, 2017, 7:23:35 AM10/8/17
to OpenPnP
Hi,

I'm using the TinyG in the LitePlacer. Now I want to define a dummy actuator to send a reset command to the controller.
As defined here, https://github.com/synthetos/TinyG/wiki/TinyG-Status-Codes#ascii-character-usage
the controller expects a CTRL-X or hexadecimal 0x18 character.

Is there any chance to send something like this via an ACTUATE_BOOLEAN_COMMAND ???

If not, I will provide a patch for OpenPNP.

Kind regards,
Karl

Cri S

unread,
Oct 8, 2017, 7:44:53 AM10/8/17
to ope...@googlegroups.com
Actually there is no way, this is the reason why grbl don't work using
Gcode driver,
As Hack, i have used this inside sendCommand
command = command.replaceAll("#!@~@!#", "\030");

but it is really a hack.
The reason is a bug inside xml data handling.
> --
> You received this message because you are subscribed to the Google Groups
> "OpenPnP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to openpnp+u...@googlegroups.com.
> To post to this group, send email to ope...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/openpnp/a0d5b39d-5768-4e1a-a3c6-1637b8c5d0be%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

Team14

unread,
Oct 8, 2017, 1:22:03 PM10/8/17
to OpenPnP
Thanks for your confirmation and also the hack. I will something similar use as you did.
What XML-Bug you are talking about?

Thanks, Karl

Cri S

unread,
Oct 8, 2017, 1:46:46 PM10/8/17
to ope...@googlegroups.com
inside XML, the CDATA[] Tag allows to send chars including binary data
that otherwise is
not legal inside xml documents. As example the sequence
CDATA[\030\030\030] should
encode 3 times 0x18 binary data.
Unfortunatly the xml library named SAX that is used in this project
have implemented
CDATA but only for printable characters and \n \r \t and problably \v .
> --
> You received this message because you are subscribed to the Google Groups
> "OpenPnP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to openpnp+u...@googlegroups.com.
> To post to this group, send email to ope...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/openpnp/73aa9684-3258-48f9-9443-313837161240%40googlegroups.com.

Team14

unread,
Oct 9, 2017, 1:11:59 AM10/9/17
to OpenPnP
I now added this lines

        if(command != null) {
            command = command.replaceAll("HEX_0x18", "\030"); // TODO 4: replace with a proper parser, to evaluate the HEX-number
        }

to the function in the GcodeDriver
public void actuate(ReferenceActuator actuator, boolean on)

To avoid, that the invisible character is trimmed (see String.trim() ), the actual COMMAND in the machine setup is surrounded by some visible characters, in my case questionmarks:
?HEX_0x18?


Cri S

unread,
Oct 9, 2017, 4:08:05 AM10/9/17
to ope...@googlegroups.com
for Grbl, it is important to use that inside Connect and especially
during Stop, so
just inside actuate it is maybe insufficient.
> --
> You received this message because you are subscribed to the Google Groups
> "OpenPnP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to openpnp+u...@googlegroups.com.
> To post to this group, send email to ope...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/openpnp/d9aaccd8-dd4d-45b4-995f-a961fc2a34d4%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages