Serial Port ActiveX(Read 51591 times)
Serial Port ActiveX on: July 26, 2012, 06:27:35 PM
Hi,

I am communicating with a serial device which reponds instead of a whole packet ended by \r\n with packets of 8 bytes (the last one with \r\n) which causes more than 1 OnRxChar event. The OnRxChar routine handles the incoming data correctly and at the end there is the the correct message in the buffer. But to interact the event handler with the software I have to know when the communication finals. How can I trigger the communication to detect the end of the incoming events?

Regards,
Marc.



Re: Serial Port ActiveX Reply #1 on: August 01, 2012, 04:57:17 PM
Hi,

Here are some of the possible solutions:

1. Keep the intermediate buffer, and handle the required number of bytes as soon as they are received.

2. Read 8 byte packets one by one in a separate thread.



Re: Serial Port ActiveX Reply #2 on: August 09, 2012, 11:06:05 AM
Hi,

we tried to put it on a seperate thread (thread, backgroundworker...)but it seems that your third party dll is executed on a "own" thread to which I do not have access. So putting my code in a separate thread seems not to work.
How do you think I have to create the thread that the event of incoming data on the serial port is handled in my thread?

We create a separate thread for write, but when onRxChar occurs the thread where this events is located is the main thread, not the one created by us...

Thanks.
« Last Edit: August 09, 2012, 12:33:58 PM by mbos »



Re: Serial Port ActiveX Reply #3 on: August 09, 2012, 04:53:33 PM
Since our ActiveX control executes in a separate thread, you don't need to use onRxChar. Just read the data from the created thread.



Re: Serial Port ActiveX Reply #4 on: August 14, 2012, 01:57:17 PM
Please give me a hint to do so. How can I read something from the port without using the onRXchar event? I tried to do so but it didn't work.



Re: Serial Port ActiveX Reply #5 on: August 16, 2012, 04:45:08 PM
Quote
Please give me a hint to do so. How can I read something from the port without using the onRXchar event? I tried to do so but it didn't work.

You should enable BlockMode:
http://wiki.eltima.com/user-guides/serial-port-ax-control/blockmode.html

Very approximately, you'll have something like this:

Code: [Select]
Sport.BlockMode = true;
while (bWork)
{
  Read (Buff, 8);
}



Re: Serial Port ActiveX Reply #6 on: August 23, 2012, 08:24:42 PM
Thanks, it's working now.



 

Sitemap 1 2 3 4 5