Zayik / CommandSender

Stream Deck plugin for sending UDP/TCP messages from a key press.
MIT License
15 stars 2 forks source link

Hex commands #14

Closed CatsBy119 closed 1 year ago

CatsBy119 commented 1 year ago

Is it possible to send commands in hexadecimal with CommandSender? For example how send: AA BB 02 0C 01

Zayik commented 1 year ago

It is. The text field backend is html, so you'll have to use the html notation. https://www.ascii-code.com/

It should be something such as \A\A \B\B ...

It looks a little messy but should do the trick. This technique was done to resolve an issue where somebody wanted to use non-printable characters such as a line feed.

CatsBy119 commented 1 year ago

Thanks for your reply.

Using Wireshark, I have found the following results:

CommandSender input: AA BB 02 0C 01 Hex code captured by Wireshark: 41 41 20 42 42 20 30 32 20 30 32 20 30 43 20 30 31

Referring to https://www.ascii-code.com/ Hex (41) = Symbol (A) Hex (42) = Symbol (B) Hex (20) = Symbol (SP) the Description is "Space"

Therefore: 41 41 20 42 42 = "AA BB"

This appears to mean that the CommandSender input needs to be in the "Symbol format". Unfortunately, that does not work because some symbols are not recognised and are interpreted as Hex 3F.

It would help if you could quote the CommandSender input that would be interpreted as HEX AA BB 02 0C 01 by the receiving device.

Thanks.

Zayik commented 1 year ago

Hey CatsBy119, I apologize for the late response. I was out on vacation for two weeks and had responded the night before heading on a plane. I noticed that my previous comment got autoformatted to not show the hex notation I had specified. And I slightly misinterpreted what you were trying to do. Was treating it as a string instead.

So if this is your hexadecimal AA BB 02 0C 01

you could do ª »    I hope I understood that correctly and that helps get you what you need. I've reopened this until I get further word whether that does the trick.

CatsBy119 commented 1 year ago

Hi David,

Thanks for reaching out. I tried your suggestion but it didn’t work.

I have attached a couple of screen snips to show you what I am trying to achieve versus what CommandSender does.

In this case I want to use CommandSender to switch the Inputs and Outputs on a 4x3 KVM switch. The KVM accepts commands in Hex format only.

FYI, I am currently using CommandSender to switch the Inputs/outputs on a 8x8 Video Matrix unit. It works brilliantly BUT that that unit was supplied with commands in both Hex and ASCII formats. I use the ASCII commands with CommandSender.

Regards,

Andrew (CaysBy119)

Snip 1. Snip 1

I have used an application called “Packet Sender” to transmit the command (in Hex) “aa bb 02 0a 02:” to my KVM switch. This particular command switches Output 1 to Input 2.

The packet transmitted is captured with “Wire Shark”.

As you can see from the screen snip, the packet transmitted contains 5 bytes and is captured in Hex as “aa bb 02 0a 02”. The ACSII representation of that is shown on the right hand side as “..”

Snip 2. Snip 2

I have used CommandSender to transmit “ª » &#2 https://github.com/Zayik/CommandSender/issues/2 ; &#12 https://github.com/Zayik/CommandSender/issues/12 ; &#1 https://github.com/Zayik/CommandSender/issues/1 ;” and have captured that packet with Wire Shark.

As you can see from the screen snip, the packet contains 29 bytes and is captured in Hex as “26 23 31 37 30 3b 20 26 23 31 38 37 3b 20 26 23 32 3b 20 26 23 31 32 3b 20 26 23 31 3b”

The ACSII representation of that is shown on the right hand side as “ª » &#2 https://github.com/Zayik/CommandSender/issues/2 ; &#12 https://github.com/Zayik/CommandSender/issues/12 ; &#1 https://github.com/Zayik/CommandSender/issues/1 ;” suggesting that CommandSender is transmitting data in ASCII format(?)

Zayik commented 1 year ago

This screenshots didn't come through. That being said, I have made the grave mistake of forgetting that I removed the string being backed by html encoding schema a while ago to make it fall in line a bit more with how packet sender can operate.

Been way too long since I've looked at this.

Try the following:

Instead of using \ÿ to represent the html notation, use the oct notation: \u0255 \u0273 ...

CatsBy119 commented 1 year ago

Snips added to previous post.

The oct notation doesn’t work either. I tried this… \u0252 \u0252 \u0273 \u0273 (Hex: AA BB)

Wire Shark captures 7 bytes (it captures the spaces too) Hex captured = 3f 20 3f 20 3f 20 3f ASCII = ? ? ? ?

Replacing the spaces with ; results in this:

Data 7 bytes Hex captured = 3f 3b 3f 3b 3f 3b 3f ASCII = ?;?;?;?

Given that both \u0252 and \u0273 are captured in Hex as “3F” it seems that it does not recognise the oct notation.

Zayik commented 1 year ago

I appreciate your patience in all of this. I've been digging into this and it turns out that an encoding I used for converting text into bytes did not support extended ascii characters. Funny enough, the encoding I was using was the ASCII encoding.

I created a pre-release which I hope can resolve the issue. https://github.com/Zayik/CommandSender/releases/tag/v1.2.0

I was able to use the following: \xaa\xbb\x02\x0c\x01

to send the hex "AA BB 02 0C 01"

image

Please give this a try :)

CatsBy119 commented 1 year ago

That works brilliantly! Thanks for all your work on this plugin,

polyh3dron commented 12 months ago

As someone who isn't very well versed on all of this, I need to send this set of Hex values to a device: 0x21 0x01 0x08 0x02 0x10 0x7D 0x0D

How do I translate this to the correct syntax for CommandSender?

kacos2000 commented 12 months ago

Hex values to a device: 0x21 0x01 0x08 0x02 0x10 0x7D 0x0D

replace the "0x" with "\x" and remove the spaces \x21\x01\x08\x02\x10\x7D\x0D

CatsBy119 commented 11 months ago

As per kacos2000's comment. Note that \x0D is a "carriage return" that may or may not be required by your device. I had to combine that hex with the ASCII commands for my video matrix as that device requires a carriage return to be entered with each IP command. For example, to switch Output 1 to Input 7 the CommandSender entry for my matrix is OUT01FR07\x0d. You will also need to add the IP address of your device and possibly a port number. My Matrix IP works on port 8000 so entered that port number and the IP address of my matrix in CommandSender and set a rule in my router to forward public port 8000 to private port 8000 (private port 8000 is linked to the IP address of my matrix). If you are still having issues, test your hex commands using a tool like Hercules 3-2-8 (a free download). That's how I discovered that I needed to add \x0D to my ASCII commands.

polyh3dron commented 11 months ago

Removing the carriage return did the trick for me!

Zayik commented 11 months ago

Glad to see people are still interested in this. I've also started a discussions page for any general questions, as they might be more visible than commenting on a closed issue. :)