Search code examples
c#.netmodemat-command

Send and read result of an At command to a usb modem in c#


I would like to know how to send and receive the result of an AT command sent to a usb modem.

I've found lot of info, but I don't know what is the best way:

I've found this : http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/800f12fa-4da8-42bf-b61b-65f6bb58c871/

But I've found the write and read kind of weird...

Somebody have something else ?

Thanks all !

EDIT :

not sure the link I paste was very great i've tried it and it gave me a null exception.

Now i'm trying this :

 SerialPort sp = new SerialPort();
            sp.PortName = "COM3";
            sp.Open();
            sp.Write("AT<CR>");

But I really don't know how to read the result, someone have an idea ?


Solution

  • (sorry for my bad english)

    I'm doing exactly the same thing in a WPF app, just hook up the sp.DataReceived event and there you could use sp.ReadExisting() to get the data.