Main Site Documentation

PPP trouble with serial modem


#1

Hi, I have a Cobra connected to a Multi-Tech analog dial-up modem. I am trying to establish socket connectivity via PPP.

Using the example code, I can get the modem to respond to commands and dial, connect, and everything is OK through PPP.Enable.

When I call PPP.Connect, I only can get a PPP.ConnectionStatus.Connection_Faild response. Does anyone have an idea of what I can try?

Using TeraTerm I can control the modem and connect to an ISP with required information (username, password). Trying the same thing through PPP.Connect() won’t work for me.

Perhaps there is a way to get more information about what may be failing?

Thanks!


#2

You need to edit the pre-connection AT coomands to match your service provider’s settings and your modem settings.

Take a look at AT command cs file.


#3

Thanks for reply, Joe, but I can connect thru TeraTerm no problem, without extra AT commands. Am I missing something? Thanks for your attention!


#4

Good, then remove the extra AT commands from the ATcommand.cs
Keep only the command that disables the echo.

I did not ask you, do your code runs AT.connect()and gets “CONNECTED” string before it runs ppp.connect()?


#5

Yes, I do get “connected 115200” before I call PPP.connect().

I am using the sample code. Any other thing I can check or investigate? Thanks.


#6

I don’t see any reason why it is not working.
Try to serial.DiscardInputBuffer() before ppp.connect()


#7

OK, I’m still having the problem. I made this very simple example code to illustrate problem. I stripped out everything and made this just for clarity.

SerialPort  aPort = new SerialPort("COM1", 115200, Parity.None, 8, StopBits.One);
            PPP.Enable(aPort);
            aPort.Handshake = Handshake.RequestToSend;
            aPort.Open();
            NetworkInterface[] netif = NetworkInterface.GetAllNetworkInterfaces();
            aPort.DiscardInBuffer();
            string aDialCmd = "ATD9010997\r";
            string aSerialReturnStr = "";
            aPort.Write(Encoding.UTF8.GetBytes(aDialCmd), 0, aDialCmd.Length);
            //Wait a good long time to allow modem to establish connection.
            Thread.Sleep(20000);

            //Read result
            while (aPort.BytesToRead > 0)
            {
                int aRespLen = aPort.BytesToRead;
                byte[] aResponse = new byte[aRespLen];
                aPort.Read(aResponse, 0, aRespLen);
                aSerialReturnStr += new string(Encoding.UTF8.GetChars(aResponse));
            }

            aPort.DiscardInBuffer();
            switch (PPP.Connect("myUserID", "myPASSWORD"))
            {
                case PPP.ConnectionStatus.Authentication_Faild:
                    Debug.Print("Authentication_Faild");
                    break;
                case PPP.ConnectionStatus.Connection_Faild:
                    Debug.Print("Connection_Faild");
                    break;
                case PPP.ConnectionStatus.Connected:
                    // PPP setting will overload the first interface settings since only one interface is supported.
                    netif = NetworkInterface.GetAllNetworkInterfaces();
                    Debug.Print("PPP Network settings:");
                    Debug.Print("IP Address: " + netif[0].IPAddress);
                    Debug.Print("Subnet Mask: " + netif[0].SubnetMask);
                    Debug.Print("Default Getway: " + netif[0].GatewayAddress);
                    Debug.Print("DNS Server: " + netif[0].DnsAddresses[0]);
                    network_is_read = false;
                    break;
                case PPP.ConnectionStatus.Disconnected:
                    Debug.Print("Disconnected");
                    break;

            }

So everything works just fine, the modem dials, connects, I get the CONNECTED 115200 string back from serial port and then PPP.Connect() returns Connection_Faild after about 30 seconds of waiting. What can I try? Thanks for any ideas anyone might have.


#8

Could you please try to connect using your PC but with only PAP authentication protocol?

I am afraid that your ISP accepts only CHAP protocol but not PAP.


#9

Hi again,

Yes I did try this, with two separate ISP’s who both told me that they accept PAP.

I accomplished successful connection via windows’s modem software (from network connections)and selected from Security Tab ‘No Encryption Allowed’ and also under Allow These Protocols selected ONLY ‘Unencrypted Password PAP’ (CHAP is also an option there that I left UNselected.)

Connection works when dialed. Thanks for your ideas so far Joe, is there anything else I can investigate? You can see that my sample code is very simple. I can try any other test!


#10

Just to make sure. You tried the ATcommand.cs instead your code to dial before, don’t you?
Are you in the US? What is yous ISP?


#11

Yes,I used the ATCommand code exactly (well, with small mods for modem stuff). My small test code boils it down to see very easily the progression of calls to GHI code.

I have been using two ISPs, just for testing purposes, Netzero and BasicISP. Reps from both companies stated that PAP works fine with any of their access numbers.

Is it possible to include any GHI code in my project for debugging purposes? Not sure if that is the way things get done here but can’t hurt to ask as I am new to this.


#12

I will contact you on your email


#13

Success!! I was able to finally get PPP.Connect() to work after I discovered that the voltages were incorrect on my TTL implementation. RTS was never going LOW, this was due to my modem development board being powered separately from the Cobra. Now the Cobra powers the modem, and the voltages are now correct (via COM2, and Handshake.RequestToSend).

Cobra Rx -> modem TTL Rx
Cobra Tx -> modem TTL Tx
Cobra RTS -> modem TTL RTS
Cobra CTS -> modem TTL CTS

Thanks so much Joe! ;D


#14

That’s Great!

It would be very nice if you share your experience with PPP and dial-up modem on a microframeworkprojects.com when you get your project done.


#15

Yes Jay…this will help others see good working examples coming from community.