KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am attempting to create a small application to collect data received from an external sensor attached to COM10. I have successfully created a small C# console object and application that opens the port and streams data to a file for a fixed period of time using a for-loop. I would like to convert this application to use the dataReceived event to stream instead. After reading the Top 5 SerialPort Tips , I still can't seem to get this to work and don't know what I am missing. I rewrote the console application so that all the code is in Main and is pasted below. Can someone please help enlighten me as to why the event handler port_OnReceiveDatazz is not being called even though I know that there is data being sent to the port by the hardware? Thanks Thanks to @Gabe , @Jason Down , and @abatishchev for all the suggestions. I am stumped and can't seem to get the event handler to work. Perhaps it has something to do with the device. I can live with just reading the port in a thread and streaming the data straight to file. Code namespace serialPortCollection { class Program { static void Main(string[] args) { const int bufSize = 2048; Byte[] buf = new Byte[bufSize]; //To store the received data. SerialPort sp = new SerialPort("COM10", 115200); sp.DataReceived += port_OnReceiveDa
Tags (comma-separated)
Save Edits
Cancel