This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2540 mini development kit

Other Parts Discussed in Thread: CC2540

Hello,

 

I'm writing my own "BTool"-like program for evaluation purposes of the CC2540 in Visual C#. I'm able to read and write data from my pc to the USB dongle, however when for instance I read all bytes available on the serial port with ComPort.readline() command, I get some strange effects. the result of this operation is of course a string. This string needs to be converted in an array of bytes; I use

System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
return encoding.GetBytes(str);

 

for thi. after this operation, I can print data in a textbox for instance. However, everything 'bigger'  than 7F if displayed as 3f. I suppose this has to do with a maximum capacity of 127(decimal) instead of required 255 for UTF8 encoding, but I have no idea to be able to print FF instead of 3f  when FF comes in on my serial port. (Of course new system.text.utf32encoding(); etc does'nt work, dus only gives 3f 00 00 00 instead of 3f...

 

Any suggestions on how te read all available data from the serial port and displaying it in a textbox?

regards

  • El dorado said:

    Hello,

     

    I'm writing my own "BTool"-like program for evaluation purposes of the CC2540 in Visual C#. I'm able to read and write data from my pc to the USB dongle, however when for instance I read all bytes available on the serial port with ComPort.readline() command, I get some strange effects. the result of this operation is of course a string. This string needs to be converted in an array of bytes; I use

    System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
    return encoding.GetBytes(str);

     

    for thi. after this operation, I can print data in a textbox for instance. However, everything 'bigger'  than 7F if displayed as 3f. I suppose this has to do with a maximum capacity of 127(decimal) instead of required 255 for UTF8 encoding, but I have no idea to be able to print FF instead of 3f  when FF comes in on my serial port. (Of course new system.text.utf32encoding(); etc does'nt work, dus only gives 3f 00 00 00 instead of 3f...

     

    Any suggestions on how te read all available data from the serial port and displaying it in a textbox?

    regards

    Update: problem fixed; one should read each byte seperately into a byte Array, without conversion to string.