Hi there
I'm currently having issues with my communication with a rs-232/serial device i have. it works. but it causes other rs-232/serial devices to stop communicating properly. i need a way to get the data from this device without using [login to view URL] or System.Threading.Thread.Sleep. when i don't use them i have no issues. but i having trouble getting the data when using readexisting for the comport. i have tried [login to view URL] but with no success. Here is the current code i use on my device data receive. The devices send data every 1 second (i found roughly 960ms) and it uses a none standard data each line composes of <new line>Value<tab>Value. i have Documentation if needed.
private void portVictronBMV_DataReceived(object sender, [login to view URL] e)
{
try
{
if (![login to view URL]) return;
string response = [login to view URL]();
[login to view URL](960);
if ([login to view URL]("\r\nPID") & [login to view URL]("Chec"))
{
string vstring2 = "";
string vstring = response;
vstring = [login to view URL]("\r\n", "@");
vstring = [login to view URL](0,1);
int stringlengh = [login to view URL];
int indexOfSteam = [login to view URL]("@Chec");
int removechar = stringlengh - indexOfSteam;
if (indexOfSteam >= 0)
vstring2 = [login to view URL](indexOfSteam, removechar);
vstring2 = vstring2 + "@CTime\t" + [login to view URL]("h:mm:ss tt");
[login to view URL](() => ProcessDataVictronBMV(vstring2));
//[login to view URL](vstring);
}
}
catch //(Exception exception1)
{
//LogMessageToFile("IPS", "Recieve Data - " + [login to view URL]);
}
}
Hi,
Its a matter of few hours for me to resolve this problem. I have been working on serial port application and .net framework for last 5 yrs.
Moreover developed many applications in embedded domain over serial port
$93 AUD in 2 days
4.9 (12 reviews)
4.4
4.4
3 freelancers are bidding on average $65 AUD for this job
You have to make receiving thread live at both side
so both side your com port is ready to listen ...
when you have to send data close the listen thread and invoke the client thread to send data ..
as it send the data close the client thread and reinvoke the listen(server) thread...
Currently when you make you thread sleep it wait but your your com port remain locked by your sleeping thread...
:) enjoy the solution ...