C# richtextbox data clipped while reading from serial port -


i writing c# program continuously take data serial port , display on rich text box of wpf. problem when use below code, first bit of every hex value clipped , output (say)

b 3c 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f  

instead of getting

0b 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff. 

why happening , mistake making? have checked terminal software , data receiving correct. while displaying in program clips first bit.

also how separate first 2 , last 2 bytes , stop being displayed on richtextbox. code below:

 string received_data = serialport1.readexisting(); char[] store_char_array = received_data.tochararray(); string display_text = "" ; foreach (var in store_char_array)       {          string hex_value = string.format("{0:x}", convert.touint32(i));   display_text += hex_value + " ";   }  invoke(new action(() => richtextbox1.appendtext(display_text))); 

thanks in advance

it problem encoding. have add when configure serial port:

serialport.encoding = system.text.encoding.getencoding(28591)


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -