1 Replies - 2597 Views - Last Post: 10 June 2010 - 12:18 AM Rate Topic: -----

#1 DiptiJain  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-June 10

Invalid Characters in Serial Port Data

Posted 10 June 2010 - 12:02 AM

Hi,

I am developing an test application to read the data coming on serial port sent by the pabx.
It is working fine. But, for some reason , i don't know why, some invalid characters are coming in the data, something like '?'
On hyperterminal i can see data in the following format
02/06/10 08:52AM 100 01 0975895420 00:00'10
But in my application it comes in the following format
0??06??0?08:5?AM????00?0??09?5?95??0?????????????????????00:00'??????????????????

Please help me.
Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: Invalid Characters in Serial Port Data

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Invalid Characters in Serial Port Data

Posted 10 June 2010 - 12:18 AM

hi i think it is the encoding. i read somewhere that if the character is unknown the byte is replaced with H3F(the question mark). i find the article:
http://social.msdn.m...d4-7db0786036e5

you can change the encoding like so:
        Dim strTmpRsInput As String = String.Empty
        Dim bytRecivedBuffer() As Byte

                    Com.Encoding = System.Text.Encoding.GetEncoding("Windows-1251")
                    strTmpRsInput = strTmpRsInput & Com.ReadExisting
                    bytRecivedBuffer = System.Text.Encoding.GetEncoding("Windows-1251").GetBytes(strTmpRsInput)



that is if you want to use cp1251 encoding.
hope it helps you :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1