serialport not sending out characters larger than 127

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="font-family:Consolas; color:blue; font-size:9.5pt If I do not encode I only get maximum character value of 63 and if I encode I get -56 which is 200 - 256. What am I doing wrong? What do I need to do to send characters between 0 and 255?
<span style="font-family:Consolas; color:blue; font-size:9.5pt Thanks,
<span style="font-family:Consolas; color:blue; font-size:9.5pt Dave
<span style="font-family:Consolas; color:blue; font-size:9.5pt
<span style="font-family:Consolas; color:blue; font-size:9.5pt #include<span style="font-family:Consolas; font-size:9.5pt
<span style="color:#a31515 "stdafx.h"
<span style="font-family:Consolas; color:blue; font-size:9.5pt #include<span style="font-family:Consolas; font-size:9.5pt
<span style="color:#a31515 "comports.h"
<span style="font-family:Consolas; color:blue; font-size:9.5pt using<span style="font-family:Consolas; font-size:9.5pt
<span style="color:blue namespace System;
<span style="font-family:Consolas; color:blue; font-size:9.5pt using<span style="font-family:Consolas; font-size:9.5pt
<span style="color:blue namespace System::IO::Ports;
<span style="font-family:Consolas; color:blue; font-size:9.5pt using<span style="font-family:Consolas; font-size:9.5pt
<span style="color:blue namespace System::Threading;
<span style="font-family:Consolas; color:blue; font-size:9.5pt using<span style="font-family:Consolas; font-size:9.5pt
<span style="color:blue namespace System::Text;

<span style="font-family:Consolas; color:blue; font-size:9.5pt int<span style="font-family:Consolas; font-size:9.5pt main(<span style="color:blue array<System::String ^> ^args)
<span style="font-family:Consolas; font-size:9.5pt {
<span style="font-family:Consolas; font-size:9.5pt String^ TestBoxPortName;
<span style="font-family:Consolas; color:blue; font-size:9.5pt int<span style="font-family:Consolas; font-size:9.5pt baudRate_9600=9600;
<span style="font-family:Consolas; font-size:9.5pt SerialPort^ TestBoxPort;
<span style="font-family:Consolas; font-size:9.5pt TestBoxPortName = <span style="color:#a31515
"com10";
<span style="font-family:Consolas; font-size:9.5pt TestBoxPort = <span style="color:blue
gcnew SerialPort(TestBoxPortName, baudRate_9600, Parity::None, 8);
<span style="font-family:Consolas; font-size:9.5pt TestBoxPort->Encoding = System::Text::Encoding::GetEncoding(28591);<span style="color:green //28591
<span style="font-family:Consolas; font-size:9.5pt TestBoxPort->Open();
<span style="font-family:Consolas; font-size:9.5pt SetPWMDuty(TestBoxPort, 4, 200);
<span style="font-family:Consolas; color:blue; font-size:9.5pt return<span style="font-family:Consolas; font-size:9.5pt 0;
<span style="font-family:Consolas; font-size:9.5pt }<span style="color:green //end of main
<span style="font-family:Consolas; color:blue; font-size:9.5pt void<span style="font-family:Consolas; font-size:9.5pt SetPWMDuty(SerialPort^ &TBComport,
<span style="color:blue char channel, <span style="color:blue unsigned
<span style="color:blue char duty)
<span style="font-family:Consolas; font-size:9.5pt {
<span style="font-family:Consolas; color:blue; font-size:9.5pt int<span style="font-family:Consolas; font-size:9.5pt i;<span>

<span style="font-family:Consolas; color:blue; font-size:9.5pt array<span style="font-family:Consolas; font-size:9.5pt <Char>^ t = {24, duty, channel, 00, 00, 00, 00, 00};
<span style="font-family:Consolas; color:blue; font-size:9.5pt for<span style="font-family:Consolas; font-size:9.5pt (i=0; i<8; i++)
<span style="font-family:Consolas; font-size:9.5pt TBComport->Write( t,i,1 );
<span style="font-family:Consolas; font-size:9.5pt }
<br/>

View the full article
 
Back
Top