Serial Port Polling

Firstly, let me preface by saying I feel silly for asking a question like this. The information should be online, but I can't seem to find it anywhere. I feel like I. Interrupt Problem Details. The symptoms depend on whether or not you have a modern serial port with FIFO. With slow polling delays at the serial port. Describes interfacing the Serial (RS-232) Port in relation to both Hardware and Software. Polling the UART is a lot slower method.

  1. See More On Stackoverflow
  2. Serial Port Monitor

. NOTICE. UPDATE YOUR BOOKMARKS!!!

We have an issue that there is no way around as of yet. I have done all I can to try and prevent this from happening.

We are going to be losing the.com,.org and.de domains. We have not been able to contact the original author of EventGhost (the person that owns those domains) to redirect them to the new web server. I set in motion when we first moved a redirection from the old server to the new server.

I also put in markers so that search engines would see this change and update any pointers they have. We still have the.net domain for the production site. And the.rocks for the test site. For the past few months you have been getting redirected to the.net site if you used one of the 3 domains mentioned above. I just wanted to tell everyone so they can make any changes needed.

I need to poll my machine via serial port. My code sorta works, I do not use streams or threads. I have not figured them out yet. IS there a way to only allow one particular method to run at a time. I think my timertick is starting the method a second or more times. One is there a way to only a method called by a timertick to be entered once until that method completes When the poll is sent with nark parity but the response must be recieved using space parity Why am I getting multiple lines in the text box from this, should only occur once I have a program that i am trying to emulate.

In tha program the event only shows up once per occurrance. Not many times like my code creates. I have used a serial port monitor program, for some reason the device is resending the same code again and again even though my app is responding same as the emulated program does. I am beginning to think that the buffer is not clearing or the parity switching is causing. But when I send commands to the device they work (I have to send the device address (mark) the command with a CRC for all bytes is sent with space parity. Text box output $11 door was opened. $11 door was opened.

$11 door was opened. $11 door was opened. $11 door was opened.

$11 door was opened. $11 door was opened. $11 door was opened. $12 door was closed.

$12 door was closed. $12 door was closed. $12 door was closed. $12 door was closed. $12 door was closed.

$12 door was closed. $12 door was closed. $12 door was closed. $12 door was closed. $12 door was closed. $12 door was closed. $12 door was closed.

$12 door was closed. $12 door was closed. $12 door was closed. There are three different timer classec in c#, if you use them in a wrong way it can really hurt. This articles explain the differences: Since your timer has an event called 'Tick', I guess its System.Windows.Forms.Timer, which is supposed to be used only for interactions with Forms.

Is using a timet the best choice? Have you thought about using DataReceived event of the SerialPort object? Althought its description is not very reasuring (for example 'Because the operating system determines whether to raise this event or not, not all parity errors may be reported.' And so on.) but once you get it to work, it works. To detect parity errors, you may also want to subscribe to ErrorReceived event Also, I had never tried to change the port's parity when it was open, so I don't know if it causes problems About your timer running before the previous finnishes processing.

See More On Stackoverflow

I suppose you can use locks to ensure your timer's method runs 'one at a time'. And are you sure you subscribe to your timer's Tick event only once? Sorry about all this, a bit incoherent, rambling:) Actually I just finnished a project similar to yours, I had to ask serial port for data periodically, receive the responses and process it. I used Elapsed event of System.Timers.Timer object to ask for data (write to the port), DataReceived event of SerialPort to receive answers (read from port, this part was a bit tricky, e.g. I used Thread.Sleep method to wait for all data to come, which - theoreticaly - I shouldn't do; but it works) and then I did all time consuming data processing (like printing, comunication with databases) using BacgroundWorkers. About how DataReceived event works. If I use the DataReceived Event The machine will not send anything until 5 seconds has elapsed since the last transmission from host computer, at that time it starts sending its address to the host.

It thinks the communications link is broken. The communications protocol is designed to work with RS485 and Fiber optic as well.

I know the program that I am trying to write my own version, becasue it lacks a database, polls the machine. I can tell that by the data captured with a serial monitoring program. I suspec it was done in 2001-2002 I just wish I could figure out what they used to code it and what libaries they used. Are you sure it is not some sort of hardware problem? What kind of connection is it? Do you use RS-485 and some sort of converter or something else?

Do you know what exactly and when exactly is sent/received by your program and at what time? There is virtual serial port emulation software that can intercept your data, so you can see what's going on. (I used it, but it was someone else who installed it so I dont realy remember what was it called). That's how I found out what was causing my problem: I asked my device for data, then, sometimes, it wasn't responding for few seconds (or even a minute). It turned out my data was sent/received correctly by the device, but the converter1 (connection device RS-485 converter1 LAN converter2 RS-232 host PC) was malfunctioning and it was holding baches of data randomly. From my experience, DataReceived event usually is received just fine and it's usually something else at fault (programming or hardware problem). Does your communication protocol include some sort of 'end of message' byte/character?

Serial Port Polling

If so, I've seen solutions on the Internet that: - use timer to ask for data - use DataReceived event and, within its method, Read(buffer, 0, bytes) or ReadExisting method to receive data and put it into a buffer. buffer is a global variable that is processed outside of DataReceived by some sort of queue and BackgroundWorker, or by another thread. Messages are distinguished using 'end of message' byte/character.

I was saying the protocol can use R232, RS485 and fibre. The machine has all 3 available on it's comm board I have used both Advanced Serial Port Monitor(AGG) and Free Serial Port Monitor (HDD) to watch the port. I have the machine configured to use RS232 The software i am trying to code so I can use my own) warns that it may have communications issue, but it never has that I noticed. Using the monitor program I noticed it thinks the port is configured 8 data bits and 2 stop bits. I should try running Advanced Serial Port Monitor on it again The software I am trying to copy sends out 0x80 and (0x80 OR'ed with address) both with wake up bit set) the machine will then send a response no wake up bits set) If the software has a commmand for the machine it sends the address (0 to 127) with wake up bit sst, then the command/instruction/data and a custom CRC with no wake up bits. The only time the machine asserts a wake up bit is when it thinks the link is broken, not getting polls from the host. There is no special end of data character sent (depending on the response the packet size will vary from 1 byte to 16 or so.

Serial Port Monitor

The only 1 byte I see is the Ack from the machine for some commands the host has to send at least 4 bytes out for command/request. Example 0x01 0x50 0x12 0x24 outbound could be address (wake bit) shutdown and 16 bit CRC these are example bytes the machine responds 0x01 if it got the command no wake up bits. It is getting framing errors Default replacement is 3F I changed it to 00, until I can figure out how to make drivers, OS and.NET Framework ignore the framing error, which might solve my issue. If I get a bad byte oh well, the crc will fail and either the host or machine will re-transmit.