Click here to Skip to main content
15,065,644 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I have Send string convert to ASCII value and Write data on serial port. then received data two times which is split two string and some times some part of string is lost.

This Following string write serail port-
(test,18042015,175332,1,0,250001015,2,2,1,0,100.00,1008,18/04/2015,0,0,0,0,0,0,0,0,0,0,0,0,1,5,test,0,167773139,B,0,1,0,0,0,0,64(

Recieved string- 42015,175332,1,0,250001015,2,2,1,0,
Posted
Updated 18-Apr-15 2:36am
v4
Comments
OriginalGriff 18-Apr-15 7:07am
   
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
So try showing us your code fragments and a sample of the data sent and received.
Use the "Improve question" widget to edit your question and provide better information.
[no name] 18-Apr-15 20:27pm
   
AND WHAT IS THE PB?
OriginalGriff 19-Apr-15 2:01am
   
Ok, I see a received fragment of the TX string - but that doesn't really tell us anything about *why* it's a problem.
As I suggested yesterday we need the relevant code fragments.
Member 8547973 20-Apr-15 0:38am
   
void comPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
//determine the mode the user selected (binary/string)
switch (comm.CurrentTransmissionType)
{
//user chose string
case CommunicationManager.TransmissionType.Text:
//read data waiting in the buffer
string msg = comPort.ReadExisting();
//display the data to the user
DisplayData(CommunicationManager.MessageType.Incoming, msg + "\n");
break;
//user chose binary
case CommunicationManager.TransmissionType.Hex:
//retrieve number of bytes in the buffer
int bytes = comPort.BytesToRead;
//create a byte array to hold the awaiting data
byte[] comBuffer = new byte[bytes];
//read the data and store it
comPort.Read(comBuffer, 0, bytes);
//display the data to the user
DisplayData(CommunicationManager.MessageType.Incoming, comm.ByteToHex(comBuffer));
break;
case CommunicationManager.TransmissionType.Ascii:
//retrieve number of bytes in the buffer
int bytess = comPort.BytesToRead;
//create a byte array to hold the awaiting data
byte[] comBufferr = new byte[bytess];

//read the data and store it
comPort.Read(comBufferr, 0, bytess);
//display the data to the user
DisplayData(CommunicationManager.MessageType.Incoming, comm.ByteToString(comBufferr) + "\n");

break;
default:
//read data waiting in the buffer
string str = comPort.ReadExisting();
//display the data to the user
DisplayData(CommunicationManager.MessageType.Incoming, str + "\n");
break;
}
}
Member 8547973 20-Apr-15 1:57am
   
Please give any idea sir.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900