Highlighted
Absent Member.
Absent Member.
864 views

Managed Code Encoding Serial Port

Jump to solution

Hi Community!

I have encountered a problem sending data past x"3F" over a serial port in managed code. In the docs I read you need to set the encoding to go past the 7-Bit(??) limit. So I did the following:

set serialPort1::Encoding to type System.Text.Encoding::GetEncoding(737) *> tried other values like 1252 as suggested in different forums. But when I do:

invoke serialPort1::Write(x"FF") *> it results in 3F being sent. where is Bit 8?

Somehow I don't get the catch. Should be simple though. I hope someone has an answer.

Regards

Rainer

0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: Managed Code Encoding Serial Port

Jump to solution

I found out.

You don't need to set any encoding to the port. Just define the data as i.e.

      01 ReadSerialNo             type Byte[] value x"04FF11EA". *> Read Transponder No.

and send it:

          invoke serialPort1::Write(ReadSerialNo, 0, 4)

of course 4 is BytesToWrite.

I was confused by intellisense which explains the "Write" function with "Text as String": Should be corrected.

Thanks anyway

Rainer

View solution in original post

0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.

RE: Managed Code Encoding Serial Port

Jump to solution

I found out.

You don't need to set any encoding to the port. Just define the data as i.e.

      01 ReadSerialNo             type Byte[] value x"04FF11EA". *> Read Transponder No.

and send it:

          invoke serialPort1::Write(ReadSerialNo, 0, 4)

of course 4 is BytesToWrite.

I was confused by intellisense which explains the "Write" function with "Text as String": Should be corrected.

Thanks anyway

Rainer

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.