TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > VB.NET

Serial port encoding

VB.NET

 
 
Thread Tools Display Modes
Unread 11-10-2007, 05:03 AM   #1
Jack Russell
Guest
 
Posts: n/a
Serial port encoding

I am trying to use the serial port control to send and receive 8 bit
characters to/ from a n instrument. whatever I set encoding to it
converts the characters.

Any ideas how to stop it?

Thanks

Jack Russell
 
Unread 11-10-2007, 12:05 PM   #2
Armin Zingler
Guest
 
Posts: n/a
Re: Serial port encoding

"Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
> I am trying to use the serial port control to send and receive 8 bit
> characters to/ from a n instrument. whatever I set encoding to it
> converts the characters.
>
> Any ideas how to stop it?


Can you give an example of the sent/received data? How did you find out that
it gets converted? How do you send the data (code)?


Armin

 
Unread 11-10-2007, 08:18 PM   #3
Jack Russell
Guest
 
Posts: n/a
Re: Serial port encoding

Armin Zingler wrote:
> "Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
>
>> I am trying to use the serial port control to send and receive 8 bit
>> characters to/ from a n instrument. whatever I set encoding to it
>> converts the characters.
>>
>> Any ideas how to stop it?

>
>
> Can you give an example of the sent/received data? How did you find out
> that it gets converted? How do you send the data (code)?
>
>
> Armin

I use a serialport sniffer program
(http://www.serial-port-monitor.com/index.html)
fantastic piece of freeware.

To output I use
serialport1.write(String)

I have found that if I set encoding to zero it seems to work
serailport1.encoding=encoder.getencoding(0)
although the documentation seems to state this is an illegal operation!

 
Unread 11-10-2007, 09:13 PM   #4
Armin Zingler
Guest
 
Posts: n/a
Re: Serial port encoding

"Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
> Armin Zingler wrote:
> > "Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
> >
> > > I am trying to use the serial port control to send and receive 8
> > > bit characters to/ from a n instrument. whatever I set encoding
> > > to it converts the characters.
> > >
> > > Any ideas how to stop it?

> >
> >
> > Can you give an example of the sent/received data? How did you
> > find out that it gets converted? How do you send the data (code)?
> >
> >
> > Armin

> I use a serialport sniffer program
> (http://www.serial-port-monitor.com/index.html)
> fantastic piece of freeware.
>
> To output I use
> serialport1.write(String)
>
> I have found that if I set encoding to zero it seems to work
> serailport1.encoding=encoder.getencoding(0)
> although the documentation seems to state this is an illegal
> operation!


Which encoding does the device expect?


Armin

 
Unread 12-10-2007, 04:04 AM   #5
Jack Russell
Guest
 
Posts: n/a
Re: Serial port encoding

Armin Zingler wrote:
> "Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
>
>> Armin Zingler wrote:
>> > "Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
>> > > > I am trying to use the serial port control to send and receive 8
>> > > bit characters to/ from a n instrument. whatever I set encoding
>> > > to it converts the characters.
>> > > > > Any ideas how to stop it?
>> > > > Can you give an example of the sent/received data? How did you
>> > find out that it gets converted? How do you send the data (code)?
>> > > > Armin

>> I use a serialport sniffer program
>> (http://www.serial-port-monitor.com/index.html)
>> fantastic piece of freeware.
>>
>> To output I use
>> serialport1.write(String)
>>
>> I have found that if I set encoding to zero it seems to work
>> serailport1.encoding=encoder.getencoding(0)
>> although the documentation seems to state this is an illegal
>> operation!

>
>
> Which encoding does the device expect?
>
>
> Armin

This is the point, I and a lot of other people use serial ports to
transmit binary data, we do not want any encoding. According to the help
files the default is 7 bit ascii, but you can set the various unicode
alternatives. The help file says that setting 0 gives the "default"
which is patently not true
 
Unread 12-10-2007, 01:06 PM   #6
Armin Zingler
Guest
 
Posts: n/a
Re: Serial port encoding

"Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
> Armin Zingler wrote:
> > "Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
> >
> > > Armin Zingler wrote:
> > > > "Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
> > > > > > I am trying to use the serial port control to send and
> > > > > > receive 8
> > > > > bit characters to/ from a n instrument. whatever I set
> > > > > encoding to it converts the characters.
> > > > > > > Any ideas how to stop it?
> > > > > > Can you give an example of the sent/received data? How did
> > > > > > you
> > > > find out that it gets converted? How do you send the data
> > > > (code)?
> > > > > > Armin
> > > I use a serialport sniffer program
> > > (http://www.serial-port-monitor.com/index.html)
> > > fantastic piece of freeware.
> > >
> > > To output I use
> > > serialport1.write(String)
> > >
> > > I have found that if I set encoding to zero it seems to work
> > > serailport1.encoding=encoder.getencoding(0)
> > > although the documentation seems to state this is an illegal
> > > operation!

> >
> >
> > Which encoding does the device expect?
> >
> >
> > Armin

> This is the point, I and a lot of other people use serial ports to
> transmit binary data, we do not want any encoding.


If you send strings, they /do/ have an encoding. Every character does have a
number (one or two bytes).

Only zero-length strings don't have an encoding. :-)

> According to the
> help files the default is 7 bit ascii, but you can set the various
> unicode alternatives. The help file says that setting 0 gives the
> "default" which is patently not true


"Default" usually means "ANSI" code page, which you can get from
System.Text.Encoding.Default.

In any case you must know which encoding the receiver expects.

As you probably know, Strings are stored as Unicode (2 bytes), so if you
want to send them with any other encoding, you must convert to an array of
bytes (Encoding.GetBytes).


Armin

 
Unread 12-10-2007, 09:12 PM   #7
Jack Russell
Guest
 
Posts: n/a
Re: Serial port encoding

Armin Zingler wrote:
> "Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
>
>> Armin Zingler wrote:
>> > "Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
>> >
>> > > Armin Zingler wrote:
>> > > > "Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
>> > > > > > I am trying to use the serial port control to send and
>> > > > > > receive 8
>> > > > > bit characters to/ from a n instrument. whatever I set
>> > > > > encoding to it converts the characters.
>> > > > > > > Any ideas how to stop it?
>> > > > > > Can you give an example of the sent/received data? How did
>> > > > > > you
>> > > > find out that it gets converted? How do you send the data
>> > > > (code)?
>> > > > > > Armin
>> > > I use a serialport sniffer program
>> > > (http://www.serial-port-monitor.com/index.html)
>> > > fantastic piece of freeware.
>> > >
>> > > To output I use
>> > > serialport1.write(String)
>> > >
>> > > I have found that if I set encoding to zero it seems to work
>> > > serailport1.encoding=encoder.getencoding(0)
>> > > although the documentation seems to state this is an illegal
>> > > operation!
>> >
>> >
>> > Which encoding does the device expect?
>> >
>> >
>> > Armin

>> This is the point, I and a lot of other people use serial ports to
>> transmit binary data, we do not want any encoding.

>
>
> If you send strings, they /do/ have an encoding. Every character does
> have a number (one or two bytes).
>
> Only zero-length strings don't have an encoding. :-)
>
>> According to the
>> help files the default is 7 bit ascii, but you can set the various
>> unicode alternatives. The help file says that setting 0 gives the
>> "default" which is patently not true

>
>
> "Default" usually means "ANSI" code page, which you can get from
> System.Text.Encoding.Default.
>
> In any case you must know which encoding the receiver expects.
>
> As you probably know, Strings are stored as Unicode (2 bytes), so if you
> want to send them with any other encoding, you must convert to an array
> of bytes (Encoding.GetBytes).
>
>
> Armin

Sorry, I am not sending "strings" I am sending binary data. This is very
common with serial port applications. I want the 8 bits to be sent
exactly as is with no "translation". Every other serial port "driver" I
have ever seen can do this why cant .net

 
Unread 12-10-2007, 10:08 PM   #8
Armin Zingler
Guest
 
Posts: n/a
Re: Serial port encoding

"Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
> >
> >
> > Armin

> Sorry, I am not sending "strings" I am sending binary data.



You wrote:

serialport1.write(String)


I thought String means String. Now you write, you don't send a String.
What's right now?


Armin

 
Unread 12-10-2007, 11:13 PM   #9
Göran Andersson
Guest
 
Posts: n/a
Re: Serial port encoding

Jack Russell wrote:
>> Which encoding does the device expect?
>>
>>
>> Armin

> This is the point, I and a lot of other people use serial ports to
> transmit binary data, we do not want any encoding. According to the help
> files the default is 7 bit ascii, but you can set the various unicode
> alternatives. The help file says that setting 0 gives the "default"
> which is patently not true


The solution is very simple. If you want to send binary data, send
binary data. Don't send it as a string, send it as a byte array.

--
Göran Andersson
_____
http://www.guffa.com
 
Unread 13-10-2007, 07:06 AM   #10
Jack Russell
Guest
 
Posts: n/a
Re: Serial port encoding

Göran Andersson wrote:
> Jack Russell wrote:
>
>>> Which encoding does the device expect?
>>>
>>>
>>> Armin

>>
>> This is the point, I and a lot of other people use serial ports to
>> transmit binary data, we do not want any encoding. According to the
>> help files the default is 7 bit ascii, but you can set the various
>> unicode alternatives. The help file says that setting 0 gives the
>> "default" which is patently not true

>
>
> The solution is very simple. If you want to send binary data, send
> binary data. Don't send it as a string, send it as a byte array.
>

Thanks, just what I wanted. I should have fully read the help file I
suppose, too many years of fooling devices so it never occurred to me it
would be that easy!

Thanks again

Jack Russell
 
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding the UPS serial port under OBSD Panagiotis Atmatzidis OpenBSD 2 15-09-2007 06:51 AM
Serial port questions Jim FreeBSD 6 15-09-2007 05:29 AM
virtual serial port Goyo el Noyo Windows Mobile 7 28-08-2007 01:32 PM
Re: Help with Serial Port soup_or_power@yahoo.com Windows Server 2003 0 28-08-2007 02:37 AM
Re: USB - Serial port download problem h e l p Thomas Lutz Windows XP 0 27-08-2007 07:33 PM


< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 07:11 PM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2013, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional