From: Andrew P. on
Hello All

I'm using "modCOMM - Written by: David M. Hitchner" to send data out of the
serial port. I need to send HEX strings (eg 0E0E00000505000C20450164A5A5 ) to
external devices. Each part of the string is 2 HEX characters. If I send a
HEX string directly to it, I get incorrect data at the other end.

By using 2 HEX programs and a null cable, I can pass the strings correctly
to the equipment, and also monitor what Excel is sending out of the serial
port.

If I send this -> I get this on the HEX comms program

0E0E00000505000C20450164A5A5 ->
3045304530303030303530353030304332303435303136344135413500

0 -> 30
1 -> 31
A -> 41
a ->61
0E -> 3045
Chr(1) & Chr(255) -> 01FF

So, I can see that there is a way to get the correct data out, but I don't
want to have to encode each and every pair of HEX digits into a "chr()".
Whats the intelligent way of getting a string?

Thanks a lot!!
Andrew
From: Andrew P. on
GOT IT!!!!!

Solution:
Work on the HEX string 2 digits at a time, and take the result of Chr(), not
the string containing "Chr(xx)". And its even working in the real world, not
just a HEX editor. Happy days!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For i = 1 To Len(hexstring) Step 2
Dim temp As String
temp = WorksheetFunction.Hex2Dec(Mid(hexstring, i, 2))
outputstring = outputstring & Chr(temp)
Next i
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

"Andrew P." wrote:

> Hello All
>
> I'm using "modCOMM - Written by: David M. Hitchner" to send data out of the
> serial port. I need to send HEX strings (eg 0E0E00000505000C20450164A5A5 ) to
> external devices. Each part of the string is 2 HEX characters. If I send a
> HEX string directly to it, I get incorrect data at the other end.
>
> By using 2 HEX programs and a null cable, I can pass the strings correctly
> to the equipment, and also monitor what Excel is sending out of the serial
> port.
>
> If I send this -> I get this on the HEX comms program
>
> 0E0E00000505000C20450164A5A5 ->
> 3045304530303030303530353030304332303435303136344135413500
>
> 0 -> 30
> 1 -> 31
> A -> 41
> a ->61
> 0E -> 3045
> Chr(1) & Chr(255) -> 01FF
>
> So, I can see that there is a way to get the correct data out, but I don't
> want to have to encode each and every pair of HEX digits into a "chr()".
> Whats the intelligent way of getting a string?
>
> Thanks a lot!!
> Andrew