How To SerialPort Read asnycron

  • Thread starter Thread starter Benjamin
  • Start date Start date
B

Benjamin

Hi,

i want to read the SerialPort with .ReadExisting. But it dont work
correct. I send 224d to the prot, an the .ReadExisting got 63d, why?
And how to make it right? I want asycron read 0d-255d all the range.
But how?

best regards Benjamin
 
Hi Chris,

i solved the problem right now, i have to set Encoding to Default. Now
it works. But why is the Default not the Default ;-)

thx, Benjamin
 
Use the Read method and assign the result to an array of type Byte.
ReadExisting returns ASCII (string) data, not binary.

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
Do not depend on encoding.

This will cause problems if you deploy your application to foreign systems.
IMO, binary data should be treated as binary. See my other reply.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
Back
Top