Ya, the previous post is bugging the hecj out of me and I really don't want ppl to be frustrated if they follow it. Here's a more easy to follow procedure without the missing parts. It also includes a wifi part that will help in making a wifi Pi easier to setup, as well.
Sorry for the double posting and such... Such an 80's thing to do!
Emulating a serial modem on a Raspberry Pi
C. Reilly 30MARCH2017
This quick little project will provide a serial to tcp/ip bridge for a Raspberry Pi LINUX using tcpser and a MAX232 (or a USB to Serial adaptor). TCPSER will emulate the important Hayes commands needed to connect to telnet BBSs.
It's a great way to BBS again. Can be used from the UserPort or a swiftlink/turbo 232 and even stand up a Q-Link server and connect to it with real hardware.
TOC
---
Manditory Step - Setting up the environment properly
Step 1 - Connecting the MAX232 (if you are using a USB to Serial adaptor, skip this step)
Step 2 - Automating tcpser to start when booting the Pi
Step 3 - Setting up a wireless Pi connection without a GUI
---
Manditory Step - Setting up the environment
---
First, install Raspbian onto your Pi. I use a headless version of raspbian LINUX making it pretty light weight, fast booting and responsive. Connect an active ethernet cable and make sure you have a network connection.
Default Username: pi
Default password: raspberry
Second, note the IP address of your Pi. This is used to access the Pi for programming and maintenance. I use my router to provide the IP address and from there, I use PuTTY to telnet into the Pi to perform the rest of these instructions.
If you cannot find the IP address, connect a keyboard and a monitor to the Pi and once it's booted, logon using the default username and password to get to a bash.
Type: ifconfig eth0
Record the IP address. I recommend disconnecting the keyboard and monitor from the Pi before proceding and just remote into the Pi using PuTTY or your favourite telnet client.
If you are using a USB wireless 802.11 connection, see Step 3 to get that working. The wifi is a pretty slick way of using this project, BTW. Power can be taken from the cassette, joyport, etc. and the Pi can be tucked out of the way, giving your computer a lot more freedom and remaining tidy.
Third, install tcpser. At the bash:
type: sudo apt-get install tcpser
**Worth noting, you can use a number of USB to Serial adaptors to allow more than one baud rate/computer to be connected. The expense of power might be an issue, but it will work perfectly fine with multi tcpser commands pointing to specific ttyYUSB hardware.
Step 1 - Connecting the MAX232 (if you are using a USB to Serial adaptor, skip this step)
---
I have an old Raspberry Pi Model B and a MAX232 serial 9pin board for the Pi (it's about $1.50 for the MAX232 from ebay--I have a number of these already which is why I used them for this project). The MAX232 is connected to the Pi's GPIO port. To use the port properly, you need to disable the Pi's default setting that takes control of the poirt to monitor for remote logons. To do that, do the following:
To setup the Pi's GPIO header for serial and disable remote logon monitoring, at the bash:
Type: sudo raspi-config
Select option 5 from the menu, then select Serial from that menu. Choose No to the "login shell over serial". Then yes to "enabling the serial port hardware". While I was in there, I also overclocked the Pi, but if power is an issue, you may want to skip that suggestion. Exit out of the tool and back to the bash. There's no need to reboot the Pi.
Using the four patch wires that come with the MAX232, physically wire it to the Pi's GPIO as follows:
MAX232 Pi GPOI
------ -------
Vcc <---------> 3.3V pin 2
GND <---------> GND pin 6
Tx <---------> Rx pin 10
Rx <---------> Tx pin 8
Step 2 - Setting up the Pi to automate tcpser on boot:
---
Two text files need to be created. One is the executable file that has the instructions to start tcpser with our default values and another text file that instructs LINUX how to start the first file as a bootable service.
1. Create a text file (I just put it in the Pi home directory) and make it executable. If you are using a USB to Serial Adaptor, change the ttyAMA0 to ttyUSB0 in the following instructions (or the ttyUSB# that represents where your adaptor is active using the command: lsusb -t at the bash). Change the 38400 baud rate value in the tcpser line to whatever suites your setup.
To create the proper text file, at the bash:
type: cd <Enter>
type: vi serialBridge <Enter>
type: i
type: #!/bin/sh <Enter>
type: tcpser -s 38400 -d /dev/ttyAMA0 &
type <Esc>:wq <Enter>
You're now out of the editor and back at the bash. If you do an ls command, you should see the new file, serialBridge, in the directory. We now need to make the file executable. At the bash:
type: chmod +x serialBridge
2. Now that we have an executable file to start up tcpser with our default values, we need to create another text file that instructs LINUX how to start that file as a service when the OS boots. To do that, we create another text file in a very specific spot and then issue some commands to tell LINUX to use it when it's booting. To do that, at the bash:
type: sudo vi /lib/systemd/system/serialBridge.service <Enter>
type: i
copy and paste everything between the # mark lines into the editor (or type it in if you are a better typer than myself):
####################
[Unit]
Description=Serial to TCP-IP Bridge
After=Multi-User.target
[Install]
WantedBy=Multi-user.target
[Service]
ExecStart=/home/pi/serialBridge
type=forked
#####################
You're still in the editor at this point, so to save and exit the editor type the following: <Esc>:wq <Enter>
You will now be out of the editor and at the bash prompt. To register the executable as a service and start up the service immediately (no need to reboot), at the bash:
type: sudo systemctl enable serialBridge.service
type: sudo systemctl start serialBridge.service
type: sudo systemctl status serialBridge.service
The first command will instruct LINUX the service should be enabled at boot (level 3). The second command will tell LINUX to start the service right now (so we can use it right away without having to reboot everything). The third command will display the status of the service we just started with the previous command so we can see if it's actually enabled and ready to use. If there is a "disabled" status, then you need to go back and check your typing or if the proper device is being used, etc. If you are using a USB to Serial, the USB0 might have to be changed to ttyUSB1, etc (check to see which one is active).
Physcially connect the MAX232 to your PC with a proper cable. Turn on your PC, fire up a terminal, set the proper baud rate, and enter ATDT followed by the telnet DNS:port. Spank the Return key and see if anything connects and works as expected. I had to disable flow control to work properly, but I believe that's my cable that I was using causing that issue.
Step 3 - Using a Wireless USB 802.11 Adaptor
To connect to your secure wireless network you need to connect a keyboard and monitor to your Pi and perform the following:
type: sudo vi /etc/wpa_supplicant/wpa_supplicant.conf
**Below, wifiName refers to the name of the wifi you are connecting to. wifiPassword is the password you use to connect to your wifi. Include the quotes in your changes below.
Cursor to the bottom of the file:
type: i
type:
network={ ssid="wifiName" psk="wifiPassword"}
now type:
<Esc>:wq<Enter>
You should now be at the bash again. After a couple of moments, the wireless network should be working. It might take a few moments since the Pi has to notice the change you just made and the wifi negotiations need to finish up. It should not take any longer than 5 minutes (2 minutes is a long enough wait, IMHO).
If security is an issue and you do not want your wifi password in plain text like that, then at the bash:
type: sudo wpa_passphrase "wifiName" "wifiPassword"
This will output the encrypted psk token. Replace the psk="wifiPassword" in the wpa_supplicant.conf text-file with the token (this time without the quotes) that was produced with the above command.
Cheers,
Carl