I'm trying to send out information over the serial port to an embedded device. The idea is to convert large numbered inputs into a couple of bytes by splitting it then running char() on it.
Then converting it to a string .. therefore sending down 2 bytes as special charactors. The problem happens when sending a char that is valued over 128. For example þ or û anything thats ascii code is bigger than 128.
The string that is being sent over the serial port contains the right numbers i.e
ó| is produced as stored in string11/12 when 62332 however it will not be sent over the serial port.
The receiving code does accept these charactors as it has been tested with hyperterminal.
Code:// Read in the number from the text box and convert to int int text1 = System::Convert::ToInt32(this->textBox1->Text); int text2 = text1 >> 8; int text3 = text1 & 0x000000FF; // Bit shift the number into two differet ints wchar_t w_text11 = unsigned char(text2); wchar_t w_text12 = unsigned char(text3); // Convert the number to its ASCII equivilant String ^s_text11 = System::Convert::ToString(w_text11); String ^s_text12 = System::Convert::ToString(w_text12); //Convert the ascii equivilant to a string //Write strings to serial port this->serialPort1->Write(s_text11); this->serialPort1->Write(s_text12);
Anyone know how to send special chars over the serial port ASCII value >128 ?
Thanks.
Paul


Reply With Quote
Bookmarks