RS232 IN C++/CLI .NET2 vs2005
-
Dear all, I have been trying to send a string and read through Rs232 loop back null modem using the .net2 class serial port. The code is below: the program sort of works but does not print "hello world", it prints the number 5, which is the byte size i am looking to print. i expected "hello" to print. any ideas as to where i am going wrong? many thanks. void SendRs232Data() { serialPort->Open(); serialPort->Write("Hello World"); int offset = 0;//The offset in the buffer array to begin writing. int count = 5; //The number of bytes to read. array^ buffer = gcnew array (10);//The buffer array to write the input to. serialPort->Read(buffer, offset, count); lblSerial->Text= (serialPort->Read(buffer, offset, count)).ToString(); serialPort->Close(); }
-
Dear all, I have been trying to send a string and read through Rs232 loop back null modem using the .net2 class serial port. The code is below: the program sort of works but does not print "hello world", it prints the number 5, which is the byte size i am looking to print. i expected "hello" to print. any ideas as to where i am going wrong? many thanks. void SendRs232Data() { serialPort->Open(); serialPort->Write("Hello World"); int offset = 0;//The offset in the buffer array to begin writing. int count = 5; //The number of bytes to read. array^ buffer = gcnew array (10);//The buffer array to write the input to. serialPort->Read(buffer, offset, count); lblSerial->Text= (serialPort->Read(buffer, offset, count)).ToString(); serialPort->Close(); }
serialPort->Read(buffer, offset, count) This function returns the number of bytes read.Since u have given the count value as 5,it would always return 5.Get the expected data from the buffer array
-
serialPort->Read(buffer, offset, count) This function returns the number of bytes read.Since u have given the count value as 5,it would always return 5.Get the expected data from the buffer array