Page 1 of 1

Need advice on sending Hex over midi.

Posted: Wed Nov 18, 2009 3:52 am
by Sharp
Hi guys.

Is it normal or at least safe to convert hex to text just so you transmit it ?

When I send F0 F2 30 70 4E 00 F7 to my OASYS it's supposed to jump to COMBI mode, but when I monitor the midi channel I'm seeing 46 30 20 46 32 20 33 30 20 37 30 20 34 45 20 30 30 20 46 37

Didn't take me long to work out that my sdk exports everything as text over midi.

So just messing around here I wrote 7 lines that converted the Hex values into their text equivalents ( ðò0pN�÷ ) and exported that to a file just so I could see what it looked like in a hex editor.

Funny enough it worked and it was displayed as F0 F2 30 70 4E 00 F7 in hex format with the text still at ðò0pN�÷

Does that sound like a safe alternative or am I just asking for trouble here ?. I don't quite understand how this workaround is actually working to be honest.

Regards
Sharp

Posted: Wed Nov 18, 2009 12:37 pm
by X-Trade
what you're seeing the first time around is the ASCI value for each character you have typed in - F is 46, 0 is 30, etc.
you've got it right the second time, but unusual characters can throw off the compiler/interpreter, so thats not really good programming practice.

I don't know what program or language you are using, but if you want to write in hex there is usually a prefix, for example in C and C++ a string of hex should start with 0X and apparently the escape character (if you ever need it - it is not necessary to put on the end of a hex string, and I've never used it) is /X

so you would want to write:
0xF0F230704E00F7

you might need the gaps, i'm not sure.
are you putting them into a string or another variable type?

Posted: Wed Nov 18, 2009 2:13 pm
by Sharp
Hi X-Trade.
but unusual characters can throw off the compiler/interpreter, so thats not really good programming practice.
Thanks for that, I was worried there would be something just like that which would not be a good idea.
C and C++ a string of hex should start with 0X and apparently the escape character (if you ever need it - it is not necessary to put on the end of a hex string, and I've never used it) is /X

so you would want to write:
0xF0F230704E00F7
Thanks for that, just gave that ago and it didn't work. It's just transmitted as text. I've run every manner of search on the manual.pdf and there doesn't seem to be any way to do this just be adding 0x or anything else.

I've just sent off an email to tech support to see what they come back with.

Worst case I can write my own sysex / hex to text converter directly into the program that would avoid characters issues when compiling. It's a lot of work I shouldn't have to do though.

Kind Regards
Sharp

Posted: Wed Nov 18, 2009 5:41 pm
by Kevin Nolan
53 6f 72 72 79 20 73 68 61 72 70 20 2d 20 43 61 6e 5c 27 74 20 68 65 6c 70 20 79 6f 75 20 2d 20 6d 79 20 48 45 58 20 69 73 20 77 65 61 6b 21

3a 2d 29


52 65 67 61 72 64 73 2c 20 4b 65 76 69 6e

Posted: Wed Nov 18, 2009 5:53 pm
by X-Trade
what language are you working in? are you using quotes around the hex string?

in c-like languages for example a string is literally an array of chars so you can address it like that and put the deciman (normal) value of each hex digit directly into each element of the array.

For example (pseudo code):

string test;
stest[0]=0xF0; test[1]=0xF2; test[2]=0x30; //Hex
etc...

would be the same as:
stest[0]=240; test[1]=242; test[2]=0x48; //direct decimal values
or
stest = "ðò0" //ASCI chars

not sure if you could also do:
stest = 0xF0 F2 30;

^Which is what I was trying to say before

Posted: Wed Nov 18, 2009 5:56 pm
by lcmorley
1001110 1101111 100000
1110011 1110000 1100101 1100001 1101011 100000
1101000 1100101 1111000 101100 100000
1110011 1101111 100000
1101110 1101111 100000
1101000 1100101 1101100 1110000 100000
1100101 1101001 1110100 1101000 1100101 1110010 100001 100001

Posted: Wed Nov 18, 2009 5:59 pm
by Sharp
Kevin Nolan wrote:53 6f 72 72 79 20 73 68 61 72 70 20 2d 20 43 61 6e 5c 27 74 20 68 65 6c 70 20 79 6f 75 20 2d 20 6d 79 20 48 45 58 20 69 73 20 77 65 61 6b 21

3a 2d 29


52 65 67 61 72 64 73 2c 20 4b 65 76 69 6e
6c 6f 6c 2e 2e 2e 2e 20 6e 65 61 72 6c 79 20 77 65 74 20 6d 79 73 65 6c 66 20 6c 61 75 67 68 69 6e 67 20 77 68 65 6e 20 49 20 73 61 77 20 79 6f 75 72 20 70 6f 73 74 2e 20 :lol:

Posted: Wed Nov 18, 2009 7:02 pm
by Sharp
what language are you working in?
ADBSQL.
I'm using the SDK of brilliant database.
are you using quotes around the hex string?
Yes, but any thing I add to the string to define it as Hex gets outputted as text along with everything else.

The only thing that I can get working here right now is if I want to send F0 F2 30 70 4E 00 F7 I have to write ascript that converts it to ðò0pN�÷

If I do this internally the compiler doesn't have any problem because the file generated does indeed have the correct hex values when you output it.
string test;
stest[0]=0xF0; test[1]=0xF2; test[2]=0x30; //Hex
etc...

would be the same as:
stest[0]=240; test[1]=242; test[2]=0x48; //direct decimal values
or
stest = "ðò0" //ASCI chars

not sure if you could also do:
stest = 0xF0 F2 30;
I'll keep on trying because I would rather avoid having to build a complete internal hex to text converter just to get around this problem.

I should also get some sort of feedback from tech support by tomorrow.

Thanks for all your help.

Kind Regards
Sharp.

Posted: Fri Nov 20, 2009 6:00 pm
by Sharp
Just got my reply from Tech Support. As expected the answer is no.
So I'll just write my own convert directly into the program.

Thanks guys.

Sharp.