471,317 Members | 1,406 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

Help with SerialPort and C#

Hi there,

I'm developing an application to catch OBD sensors' data from my car.
I connect it via a RS232 interface.
Now.
with HyperTerminal I can connect and send/receive data, but I'd like to do
this from inside my C# program.
Anyone can write down a very small (or tell how to do it myself) application
containing methods like WriteToSerialPort(string what) and
ReadFromSerialPort(what).

Using the built in control SerialPort, I can correctly open a port, and
write something to it (commands like "ATX" and other worked fine from
HyperTerminal), but I can't read nothing, using SerialPort.ReadLine(). This
method always generates a Timeout exception.

What's wrong?
To send, for example, the "ATX" command through the serial port, I use
SerialPort.Write("ATX"), but nothing seems to happen.

Hope someone will help me soon!!!
Andrea
Dec 22 '05 #1
2 13284
Hi,
you should use SerialPort.ReadLine() when you recive DataReceived
event. If no event is triggered then you didn't recive any data.

Try to send SerialPort.WriteLine("ATX") or SerialPort.Write("ATX\r").

Ales

Andrea Judge je napisal:
Hi there,

I'm developing an application to catch OBD sensors' data from my car.
I connect it via a RS232 interface.
Now.
with HyperTerminal I can connect and send/receive data, but I'd like to do
this from inside my C# program.
Anyone can write down a very small (or tell how to do it myself) application
containing methods like WriteToSerialPort(string what) and
ReadFromSerialPort(what).

Using the built in control SerialPort, I can correctly open a port, and
write something to it (commands like "ATX" and other worked fine from
HyperTerminal), but I can't read nothing, using SerialPort.ReadLine(). This
method always generates a Timeout exception.

What's wrong?
To send, for example, the "ATX" command through the serial port, I use
SerialPort.Write("ATX"), but nothing seems to happen.

Hope someone will help me soon!!!
Andrea


Dec 30 '05 #2
On Thu, 22 Dec 2005 18:32:27 +0100, "Andrea Judge"
<ju***@SPAMNOGRAZIEarea51staff.it> wrote:
Hi there,

I'm developing an application to catch OBD sensors' data from my car.
I connect it via a RS232 interface.
Now.
with HyperTerminal I can connect and send/receive data, but I'd like to do
this from inside my C# program.
Anyone can write down a very small (or tell how to do it myself) application
containing methods like WriteToSerialPort(string what) and
ReadFromSerialPort(what).

Using the built in control SerialPort, I can correctly open a port, and
write something to it (commands like "ATX" and other worked fine from
HyperTerminal), but I can't read nothing, using SerialPort.ReadLine(). This
method always generates a Timeout exception.

What's wrong?
To send, for example, the "ATX" command through the serial port, I use
SerialPort.Write("ATX"), but nothing seems to happen.

Hope someone will help me soon!!!
Andrea


Send a carriage return along with your command string.

Oz
--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Dec 30 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Joshua Moore | last post: by
2 posts views Thread by Eric | last post: by
13 posts views Thread by Jean Paul Mertens | last post: by
2 posts views Thread by Jay | last post: by
6 posts views Thread by Keith Lee | last post: by
2 posts views Thread by Benedictum | last post: by
reply views Thread by cronusf | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.