vb.net - Sending Unicode Characters greater than 0x7F through RS232 -


my application in windows ce 6.0 using compact framework , being used issue remote commands device through rs-232. these commands send using bytes specific hex values, e.g. sending 0x22 0x28 0x00 0x01 command sequence. i'm sending bytes 1 @ time. hex values stored internally in string each command sequence, e.g. "22,28,00,01". i'm sending bytes using following code.

dim integer dim sendstring() string dim sendbyte, string  dutcommand = "22,0a,00,02,e7,83"     'sample command string sendstring = split(dutcommand, ",")  'split string = 0 ubound(sendstring)      'send each byte after encoding      sendbyte = chr(cint("&h" & sendstring(i)))      commport.write(sendbyte) next 

sendbyte being encoded values greater 0x7f last 2 bytes being sent (0xe7 , 0x83) being sent 0x3f, ascii code "?" since it's greater 0x7f.

am missing setting comm port handle encoding? there simple method sending data values greater 0x7f?

you forgot convert hex values bytes. needs this:

    = 0 ubound(sendstring)      'send each byte after encoding         dim b = byte.parse(sendstring(i), globalization.numberstyles.hexnumber)         commport.basestream.writebyte(b)     next 

the non-stringy way is:

    dim dutcommand byte() = {&h22, &h0a, &h00, &h02, &he7, &h83}     commport.write(dutcommand, 0, dutcommand.length) 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -