Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Problems with chr(&HC0) in vb.net

Posted on 2008-11-04
6
Medium Priority
?
745 Views
Last Modified: 2013-11-26
When I send chr(&HCO) out the serial port, I see 0x3F.  This does not happen when I send chr(&H7F) out the port on any other hex value less than 0x7F.  It appears to be an overflow issue.  Can you help?
0
Comment
Question by:gmcorbe
  • 3
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 22885640
Try sending ChrW(&HC0), instead of Chr.  That would be the Unicode representation for the character, instead of the ANSI representation (&H7F and lower).
0
 

Author Comment

by:gmcorbe
ID: 22886071
Hi,
Thanks for responding.  I already tried that.  I believe you are correct in that it's an encoding issue with the serial port in that if I send anything beyond the normal ASCII data set (0-0x3F or 0-127), it freaks and sends out the maximum 7-bit value of 0x3F.  I'm studying encoding for a serial port now.  THANKS.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 22886109
Oh, yeah, it uses AsciiEncoding by default (d'oh).

 port.Encoding = System.Text.Encoding.Default
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:gmcorbe
ID: 22886954
We're getting closer.

If I use port.Encoding = System.Text.UnicodeEncoding, I see a 0xC0 0x00 out the serial port.
System.Text..UTF7, System.Text.UTF8 did not work either.

Thanks...
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1500 total points
ID: 22889878
What code page are you using?  United States is typically 1252.

port.Encoding = System.Text.Encoding.GetEncoding(1252)
0
 

Author Closing Comment

by:gmcorbe
ID: 31513313
IT WORKED.  THANKS.  I originally used the encoding described in blog
http://blogs.msdn.com/bclteam/archive/2006/05/26/608377.aspx which indicated to use mySerialPort.Encoding = Encoding.GetEncoding(28591);  which is Western European (ISO) encoding.  This code page worked for the 0xC0 char but failed with other characters.  Your code page is working for all characters!!!!!!!!!!  NOTE that the URL blog is good reading anyway.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Loops Section Overview
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month20 days, 19 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question