Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Commiunicating with (Dial up or ADSL) Modem (or Wireless Card ) using Serial Port

Commiunicating with (Dial up or ADSL) Modem (or Wireless Card ) using Serial Port

Scheduled Pinned Locked Moved C#
sharepointtutorialquestion
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spiritboy
    wrote on last edited by
    #1

    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 ... :(

    S L 2 Replies Last reply
    0
    • S spiritboy

      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 ... :(

      S Offline
      S Offline
      Saksida Bojan
      wrote on last edited by
      #2

      AT COMMAND LIST[^] Have you considered to send AT command to modum to dial specific number

      S 1 Reply Last reply
      0
      • S Saksida Bojan

        AT COMMAND LIST[^] Have you considered to send AT command to modum to dial specific number

        S Offline
        S Offline
        spiritboy
        wrote on last edited by
        #3

        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!??

        S 1 Reply Last reply
        0
        • S spiritboy

          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 ... :(

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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

          S 1 Reply Last reply
          0
          • L Lost User

            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

            S Offline
            S Offline
            spiritboy
            wrote on last edited by
            #5

            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!

            L 1 Reply Last reply
            0
            • S spiritboy

              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!??

              S Offline
              S Offline
              Saksida Bojan
              wrote on last edited by
              #6

              I Doubt it is even possible. This is probably driver related

              1 Reply Last reply
              0
              • S spiritboy

                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!

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                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

                S 1 Reply Last reply
                0
                • L Lost User

                  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

                  S Offline
                  S Offline
                  spiritboy
                  wrote on last edited by
                  #8

                  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)

                  L 1 Reply Last reply
                  0
                  • S spiritboy

                    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)

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups