C# read byte array from SerialPort -


i ask why program returns first byte instead of byte. usb port sending byte value of 23, however, when c# program reads it, receives value of 2. why happening? c# code below

    private void button1_click(object sender, eventargs e)     {                        serialport port = new serialport("com4", 9600);         port.open();          byte[] buffer = new byte[2];          port.read(buffer, 0, 2);         handleserialdata(buffer);          port.close();     }      private void handleserialdata(byte[] respbuffer)     {         string one, two;         char a, b;          = convert.tochar(respbuffer[0]);         b = convert.tochar(respbuffer[1]);          1 = convert.tostring(a);         2 = convert.tostring(b);          messagebox.show(one + two);                 } 


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -