Zur Übersicht - INFO - Neueste 50 Beiträge - Neuer Beitrag - Suchen - Zum C-Control-I-Forum - Zum C-Control-II-Forum

Re: conversie word to hex Kategorie: IDE (von Tobias - 5.02.2017 18:36)
Als Antwort auf conversie word to hex von Bram Vooys - 4.02.2017 21:47

>
> Frends,
>
> How can I convert cnt1 to a HEX mumber
>
>  word cnt1;
>  Serial_Write(0,cnt1); // send to the host
>
> Thanks.

Dear Bram,

what you will send to the host exactly?
In your example you will send a byte with the 'Serial_Write'-function. But then it's
unimportant if you send it in binary-format (0b....), hex-format (0x....) or decimal-format.
The result, what the Serial_Write-function send is always the same. For the different
notations note in the manual "Variablen":

c=5;         // decimal-format
a=0x3ff;     // hex-format
x=0b1001;    // binary-format


But if your host need really the HEX-format in ASCII-format, you must convert it with the
'Str_Printf'-function in a character (%[width]x -> Hex-number) and send it then with
"Serial_WriteText"!
(http://www.c-control-pro.de/documentation/index.html?str_printf.htm)

I hope this information helps you. Otherwise you must send more information about your
host, maybe a datasheet!?

Regards, Tobias
 


    Antwort schreiben


Antworten:

Re: conversie word to hex (von Tobias - 5.02.2017 18:39)
    Re: conversie word to hex (von Bram Vooys - 5.02.2017 21:45)
        Re: conversie word to hex (von Tobias - 5.02.2017 23:23)
            Re: conversie word to hex (von Tobias - 5.02.2017 23:35)