Commiunicating with (Dial up or ADSL) Modem (or Wireless Card ) using Serial Port
-
hi there, i have recently posted a Question asking how to send and recieve raw ethernet packets (bits on the wire) to the dialup (or any kind of modem) Modem's Connection, i have searched a lot and found and downloaded a Library Called SharpPcap (managed code for WinPcap) that can exactly do what i want, but only over Lan Connection and when i was trying to send packets over Dialup connection it fails, someone answers me and tell me to send packets using SerialPort class, since Modems are connected to the computer using serial ports(like COM1 or COM2) now suppose that my dial up modem is connected to the internet and is at port COM1, i'll wrote something like this:
SerialPort sp = new SerialPort("COM1",9600); sp.DtrEnable = true; sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived); sp.Open();//Throws an exception Here sp.Write(....My Packet);
as i specify it throws me an exception, since this port is Opened now and is owned by a process, and as long as ports(such as COM1) can only be used by one and only one process, i can not do any thing... is there another way or something else, i've searched for 2 or more weeks ... :( -
hi there, i have recently posted a Question asking how to send and recieve raw ethernet packets (bits on the wire) to the dialup (or any kind of modem) Modem's Connection, i have searched a lot and found and downloaded a Library Called SharpPcap (managed code for WinPcap) that can exactly do what i want, but only over Lan Connection and when i was trying to send packets over Dialup connection it fails, someone answers me and tell me to send packets using SerialPort class, since Modems are connected to the computer using serial ports(like COM1 or COM2) now suppose that my dial up modem is connected to the internet and is at port COM1, i'll wrote something like this:
SerialPort sp = new SerialPort("COM1",9600); sp.DtrEnable = true; sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived); sp.Open();//Throws an exception Here sp.Write(....My Packet);
as i specify it throws me an exception, since this port is Opened now and is owned by a process, and as long as ports(such as COM1) can only be used by one and only one process, i can not do any thing... is there another way or something else, i've searched for 2 or more weeks ... :(AT COMMAND LIST[^] Have you considered to send AT command to modum to dial specific number
-
AT COMMAND LIST[^] Have you considered to send AT command to modum to dial specific number
-
hi there, i have recently posted a Question asking how to send and recieve raw ethernet packets (bits on the wire) to the dialup (or any kind of modem) Modem's Connection, i have searched a lot and found and downloaded a Library Called SharpPcap (managed code for WinPcap) that can exactly do what i want, but only over Lan Connection and when i was trying to send packets over Dialup connection it fails, someone answers me and tell me to send packets using SerialPort class, since Modems are connected to the computer using serial ports(like COM1 or COM2) now suppose that my dial up modem is connected to the internet and is at port COM1, i'll wrote something like this:
SerialPort sp = new SerialPort("COM1",9600); sp.DtrEnable = true; sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived); sp.Open();//Throws an exception Here sp.Write(....My Packet);
as i specify it throws me an exception, since this port is Opened now and is owned by a process, and as long as ports(such as COM1) can only be used by one and only one process, i can not do any thing... is there another way or something else, i've searched for 2 or more weeks ... :(spiritboy wrote:
Throws an exception Here
What exception is it throwing?
spiritboy wrote:
since this port is Opened now
No it is not opened, it threw an exception.
spiritboy wrote:
and is owned by a process
Do you mean to say the some other program has the serial port open already and you want to use both of your programs for the same serial port at the same time? I am not so sure that you can share a serial port.
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns Help humanity, join the CodeProject grid computing team here
-
spiritboy wrote:
Throws an exception Here
What exception is it throwing?
spiritboy wrote:
since this port is Opened now
No it is not opened, it threw an exception.
spiritboy wrote:
and is owned by a process
Do you mean to say the some other program has the serial port open already and you want to use both of your programs for the same serial port at the same time? I am not so sure that you can share a serial port.
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns Help humanity, join the CodeProject grid computing team here
the Exception is IOExceptio and telling : "The process cannot access the port 'COM1' because it is being used by another process." the reason is that my modem is already connected to the internet (so is under used by another process), and i want to send packets to it. when the modem is not connected i can successfully Open the port. to make it more clear, i do not have another program that opened this port!
-
i didn't ask what to send to modem, i have asked how to communicate when the port is opened by another process and i want to open() it and send AT Commands!??
I Doubt it is even possible. This is probably driver related
-
the Exception is IOExceptio and telling : "The process cannot access the port 'COM1' because it is being used by another process." the reason is that my modem is already connected to the internet (so is under used by another process), and i want to send packets to it. when the modem is not connected i can successfully Open the port. to make it more clear, i do not have another program that opened this port!
spiritboy wrote:
my modem is already connected to the internet
spiritboy wrote:
another program that opened this port
What you are saying contradicts yourself. If the port is opened by another process then by definition something else opened the port. You cannot open an already opened port. If as you say your program has the port open, why don't you just start sending packets to it? In other words, you are trying to open a port you already have open when there is no need to open it again.
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns Help humanity, join the CodeProject grid computing team here
-
spiritboy wrote:
my modem is already connected to the internet
spiritboy wrote:
another program that opened this port
What you are saying contradicts yourself. If the port is opened by another process then by definition something else opened the port. You cannot open an already opened port. If as you say your program has the port open, why don't you just start sending packets to it? In other words, you are trying to open a port you already have open when there is no need to open it again.
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns Help humanity, join the CodeProject grid computing team here
I am sorry for this, again! i said my modem is connected to the internet!!! when it is connected to internet i can not Open its port since it is connected to the internet, i am not trying to open port for second time! all i need is to send packets over dialup. more explanation: when i go to StartMenu\Connect to\My dial up Connection\Dial then i can not Open the modem Port. i do not have a second program running and using the port. the process that is using the port is one of windows processes. i did not contradict myself, i said: while modem is connected (by StartMenu\Connect to\My dial up Connection\Dial) i want to send packets! the way i found is to use serial port, but while my modem is connected i cannot Open its port in my program unless , myself in the program dial and connect to the ISP.(not using StartMenu\Connect to\My dial up Connection\Dial)
-
I am sorry for this, again! i said my modem is connected to the internet!!! when it is connected to internet i can not Open its port since it is connected to the internet, i am not trying to open port for second time! all i need is to send packets over dialup. more explanation: when i go to StartMenu\Connect to\My dial up Connection\Dial then i can not Open the modem Port. i do not have a second program running and using the port. the process that is using the port is one of windows processes. i did not contradict myself, i said: while modem is connected (by StartMenu\Connect to\My dial up Connection\Dial) i want to send packets! the way i found is to use serial port, but while my modem is connected i cannot Open its port in my program unless , myself in the program dial and connect to the ISP.(not using StartMenu\Connect to\My dial up Connection\Dial)
spiritboy wrote:
i did not contradict myself
Sorry, whether you realize it or not, you are contradicting yourself. You say:
spiritboy wrote:
i am not trying to open port for second time
and then:
spiritboy wrote:
the process that is using the port is one of windows processes.
So slowly. The reason that you cannot open the serial port the second time is because you already have it open with another program! That is what the other process is! If you want to open the serial port again, you have to shut down the other program, process or alien intelligence that is using it first. Whether you started the process or Windows started the process does not matter at all. You can only have the serial port open by one process at a time.
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns Help humanity, join the CodeProject grid computing team here