How to use hexadecimal write on serial port

Asked

Viewed 59 times

1

I have a java routine to print on a serial port. I need to pass this routine to c# are very similar, but I believe I’ve bumped into some differences:

        byte btCmds[] = new byte[200];
        stValue = "748";      //Banco
        btCmds[1] = (byte)0xA2;    
        btCmds[0] = 0x1B;    
        for(wdCnt=0;wdCnt < stValue.length() ;wdCnt++ ){
            btCmds[wdCnt+2] = stValue.getBytes()[wdCnt];
            }
            btCmds[wdCnt+2] = 0x0D;
            szCmds = wdCnt+3;     
            for(int Count = 0;Count <  szCmds; Count ++) 
                { serialPort.writeByte(btCmds[Count]); }

my main question is in the command: Write(Byte[], Int32, Int32) did not understand the syntax. If I have to make a loop as in java and will print character by character or if it already controls this putting: {serialPort.Write (btCmds[Count],0,szCmds); } another doubt: byte btCmds[] or char thank you in advance

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.