Currently, the serial communication between PC and PLC is causing a loss of received data.
When I checked the received data in the log on the software, I found that the first 16 Byte was received.
As a countermeasure, we increased the interrupt priority to move the data in the FIFO buffer to the main memory (with a new DWORD 32-bit value added in the registry PriorityControl, setting the target COM port priority to "2").
Reference Site:
Windows RS-232C serial communication is missing received data
Although we have made significant improvements in the above correspondence, we can see that the data received is still missing.
So I have a question.
Thank you for your cooperation.
I will add the following.Thank you for your cooperation.
//' bubble clear
try
{
Obj.DiscardOutBuffer();// Clearing the Transmit Buffer
Obj.DiscardInBuffer(); // 'Incoming Buffer Clear
}
catch (Exception exp)
{
return-1; // '[NG] Transmit/receive buffer clear
}
myComStatusParams.Serial.PLC.ReceiveData=";//'ReceiveDataClear
/// Send FINS commands
rtn = SerialDataSend (refObj, strCommand);
if(rtn==false)
return-2;
myComStatusParams.Serial.PLC.TickCount=0;//'Timeout Monitoring Cantor Initialization
return1;
# receiving program
①private voidSerialPortStage_DataReceived (object sender, System.IO.Ports.SerialDataReceivedEventArgse)
{
Serial.myComStatusParamsStage.Serial.PLC.ReceiveData+=SerialPortPLC.ReadExisting();
}
② private voidSerialPortStage_DataReceived (object sender, System.IO.Ports.SerialDataReceivedEventArgse)
{
do
{
US>//#string StrLDReceiveData=";
US>string Delimiter="\r\n";
do
{
// Receive 1 byte at a time (character at a time)
StrLDReceiveData+=((char)(SerialPortPLC.ReadChar())).ToString();
} while(StrLDReceiveData[StrLDReceiveData.Length-1]!=Delimiter[Delimiter.Length-1]);
} while (SerialPortPLC.BytesToRead!=0);
}
We checked the occurrence status of the data loss using the method of receiving 、 and の, but the occurrence status did not change in ② and に
(However, the verification of measures to increase interruption priority is not carried out under the method of 2)
[Additional note]
GUI application.
The transmission is running on a dedicated thread.
The event handler received above is on the main thread.
There will be no load to cause data loss in the program of the part presented.
This is because the DataReceived handler does not change the situation either way.
If I have to say anything, I am concerned about the following points.
In addition, please check other parts of the application that are not mentioned in the questionnaire for the following actions:If so, take action to ensure that they do not affect data reception.
By the way, if possible, it would be better to use the development environment/library/tools provided by the manufacturer than to create a program with C# scratch.
Performance and functionality have been verified, and they should be able to deal with any problems.
Maybe these are related software.
Software-Product Category|Omron Controller
FA Integration Tool Package CX-One
Sysmac Library
Daikanyama 32 (Simple Data Collection Software)
© 2024 OneMinuteCode. All rights reserved.