Click here to Skip to main content
15,358,707 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to send the (x, y) co-ordinate to a CNC machine using the SerialPort. The co-ordinates will upload by user which is around 30-200 lines. While sending the co-ordinates less than 40 lines. All the data are received on the CNC machine . if the number of the exceeding from 50 .. some data received with loss of some digits mention below.. here X is loss in received data .

data send

data received

header + "\x25" + "\x0A"+ "O00000010"+ "\x0A" +" "+"\x0A" + "(from pc) "+ "\x0A" 
header is a ASCII code for header and footer,O00000010 is a program number ,(from pc) is a comment of the program, + 

i cannot figured out the problem .. is it a application error ???

What I have tried:

<pre>		if (this->serialPort->IsOpen)
		{         String^ txt = richTextBox6->Text;
             if (richTextBox6->Lines->Length > 0)
serialPort->Write(header + "\x25" + "\x0A"+ "O00000010"+ "\x0A" +" "+"\x0A" + "(from pc) "+ "\x0A" + txt + "\x0A" + "\x25" + header);
Updated 28-Oct-21 5:06am

I did not study all that code in any detail.

The successful transmission depending on the amount of data tells me something, probably inside the receiver, can't keep up; so there would a problem either with buffering, with timing, or with handshaking.

You seem to be sending all data with a single SerialPort->Write. That does not sound wise. You could transmit smaller chunks of data, say:
- the header part
- the data lines one by one
- the tail part
And you could even insert a small delay (say some 20 msec) after each Write.

If that works perfectly you could leave it at that; or you could then further experiment and pinpoint the exact cause.

PS: I would also be inclined to drop those "\x0A", explicitly set Serial->NewLine to what you need, and use SerialPort->WriteLine instead.
We can't tell - we have no idea what your code is doing when it receives the data.

So start with the basics and use Hyperterminal or similar to look at exactly what is going on, what data is being sent to the receiver.
If that's correct and missing nothing, then it's your receiver code (that we can't see).
If it's missing the same data, it's the sending app or a configuration error.

Sorry, but we can't do any of that for you!

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