Nicolas Nackel / Mbed 2 deprecated PPP-Blinky

Dependencies:   mbed

You are viewing an older revision! See the latest version

Homepage

TCP/IP Networking Over the MBED Virtual Com Port is Possible

/media/uploads/nixnax/ppp-blinky.jpg

This program shows how mbed-enabled hardware with a USB virtual serial port can interface as a standard Dial-up Networking Adapter in Windows 7 and Windows 8.

The program waits for the string CLIENTCLIENT from the PC, on the USB virtual serial port.

Upon receiving the string, it sends a response: CLIENTSERVER.

The response string CLIENTSERVER is interpreted by the Windows unimodem driver as a CONNECT response.

Windows assumes the connection is made and starts sending PPP link packets - we have the beginning of a TCP connection!

This program detects the PPP frames and toggles LED1 every time a frame is found.

Trying It Yourself

Plug your MBED board into your host PC USB port. You need a board with a virtual COM port. I used the ST-Micro Nucleo-L476RG. Compile the code for your board and download it.

You can manually test the code by opening a terminal program such as Tera Term, and setting the relevant USB Virtual Com port to 115200 baud. Nothing will happen until you type CLIENTCLIENT (there is no echo) when you will see "CLIENTSERVER" sent from the board. LED1 should toggle for every two 0x7E characters you send. Don't forget to close the port when your'e done testing, or Windows Dial-up Networking will report that the com port is in use by another program.

Creating a Dial-up Networking Adapter on Windows

/media/uploads/nixnax/modem.jpg

To test this with your Windows 7 or 8 PC, you have to create a new modem. The process should go roughly like this https://technet.microsoft.com/en-us/library/cc726048(v=ws.10).aspx, and you have to choose Communications cable between two computers under Standard Modem Types.

When asked which serial port to use, select your MBED board's USB virtual COM port. Finally, go to Modem properties and set the baud rate of the modem serial port to 115200 baud.

In windows networking, create a new Dial-up networking adapter by choosing Setting up a new network connection and then choosing Connect to the Internet. You will be told You are already connected to the internet, but click Set up a new connection anyway and choose the new modem that you have created. Even though it's a direct connect link, you have to enter a phone number to dial, so just enter 1.

With the the code running on your MBED board, you should see LED1 turn on as soon as you click Connect on your PC, signaling that the code detected the "CLIENTCLIENT" string from the PC.

After the PC receives the correct response CLIENTSERVER, it will try to establish an "internet" (PPP) connection with your MBED board, and you will see Verifying User Name and Password in the status box. You have just proven that a USB-PPP networking connection is possible!

Dealing with the Windows 7/8/10? Error 777 Bug

There is a really annoying bug in Windows 7/8/10 Dial-Up networking. It's likely that you will run into it.

If you see Error 777 instead of "Verifying User Name and Password" and LED1 never turns on, you have to manually edit a file named rasphone.pbk, find a string Type=1 and change it to Type=3.

/media/uploads/nixnax/rasphone.jpg

Note that this string will be modified back to Type=1 every time Windows saves phone book information (e.g. the phone number) so you have to remain vigilant for Error 777 and go back in to repeat the fix! You will probably have to do this many times.

It's a well known bug and you can read all about it, including finding the location of rasphone.pbk, here: http://stackoverflow.com/questions/7953376/ppp-connection-through-serial-cable-works-on-windowsxp-but-doesnt-work-on-windo

After Connect

Once everything is working you establish a dial-up connection to your mbed board over the USB virtual com port.

The IP address you manually assigned to the new dial-up network adapter functions as a gateway to any valid IP address on that subnet. In the screen capture below, I'm sending pings from the Windows 8 command line to my ST-Micro Nucleo-L476RG board over the USB virtual serial Port. I'm using a second serial port and Tera Term to capture the debug output from a second serial port on the hardware. I've also added the hostname mbed-PPP-Blinky to my Windows hosts file so I don't have type in the IP every time. The debug output from the board prints out the IP source and destination address and the first few bytes of the data payload. Note that the source is the adapter IP address, and the destination is some other address on that subnet - all packets to that subnet are sent to our mbed hardware.

/media/uploads/nixnax/ppp-blinky-online.jpg

Webserver Working

PPP-Blinky contains enough smarts to work with web browsers such as Internet Explorer, Mozilla Firefox, Google Chrome and Curl.

In this picture Internet Explorer renders a small web page that's embedded in PPP-Blinky's code.

/media/uploads/nixnax/ppp-blinky-webserver.jpg

Pings are Fast!

In the screen shot below the ICMP ping reply routine was compiled with printfs commented out. The ping reply for a short ping (8 bytes of data) was around 12 milliseconds on the Nucleo-L476RG board at 115200 baud.

/media/uploads/nixnax/fast-ping-test.jpg


All wikipages