Home‎ > ‎HowTo‎ > ‎

Use Bifferboard as Serial-to-Network adapter

There is already dedicated hardware that implements Serial-to-Network (Serial to Ethernet) functionality, but using a Bifferboard will make it possible to add extra features without having to add more hardware.
The initial idea was to design dedicated hardware to receive serial data from Solar Panels (some Solar Panels send internal temperature data to RS232 interface) and send that data over a TCP/IP network to a remote server (remote server would be responsible for logging data into database/files/etc). Since the adapter would need to be next to the Solar Panels (on the roof) it could also implement extra functionality such as micro-weather-station, external webcam surveillance, etc!

To implement the following tutorial it is required to be able to:
i) Compile Firmware: http://sites.google.com/site/bifferboard/Home/howto/compile-firmware
ii) Flash kernel and copy rootfs to USB Pendrive: http://sites.google.com/site/bifferboard/Home/howto/flash-kernel

It also requires some extra hardware:
a) USB Pendrive required for the rootfs
b) Voltage level adapter for Bifferboard RS232 interface (e.g: one MAX3232 chip with 5 polarized capacitors to convert 3.3VDC lines to standard RS232 voltage levels)
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1068

1) Dettach Bifferboard Serial port from Linux OpenWrt OS (customize firmware)

source: http://sunspot.co.uk/Projects/Bifferboard/serial/serial_no_chatter.html

Bifferboard Serial port by default is used by the OS, it can be used to check for boot problems or  to connect to BB via Serial console. To Remove this functionality it is required to re-adjust the kernel configs, re-compile the firmware and flash Bifferboard and set new rootfs:

1.a) Before compiling the new firmware from i) it is required to (Linux desktop machine - cross-compiling enviornment):

> cd bifferboard
> cd openwrt
> make kernel_menuconfig

Un-check: Device Drivers -> Character devices -> Serial Drivers -> Console on 8250/16550 and compatible port
Un-check: kernel hacking -> Early printk
Exit -> Save -> Yes

> cd ..
>make remake V=99

1.b) Add ser2net application to firmware (still on Linux desktop machine):

>make menuconfig

check: Network -> ser2net
Exit -> Save -> Yes

>make remake V=99

1.c) Flash kernel and copy rootfs ii)

Don't remove rootfs USB prendrive yet!

1.d) Remove Serial Console interaction (USB pendrive from rootfs)

After copying rootfs to USB Pendrive (/media/Bifferboard) it is required to comment the following line from /etc/inittab:

>sudo nano /media/Bifferboard/etc/inittab

ttyS0::askfirst:/bin/ash --login
replace with:
::ttyS0::askfirst:/bin/ash --login

1.e) Edit ser2net.conf settings

>sudo nano /media/Bifferboard/etc/ser2net.conf

Comment all examples by adding # to the begining of each line and add new configuration (Serial Communication settings: 115200N81):

2005:raw:600:/dev/ttyS0:115200 NONE 1STOPBIT 8DATABITS -XONXOFF -LOCAL -RTSCTS

Finally dettach USB Pendrive, connect it to Bifferboard and boot your system.

2) Final tests

After booting Bifferboard it is required to make the proper procedures to gain access via SSH to launch ser2net application. Don't forget to telnet into Bifferboard and run passwd command to set new pass! Reboot your system and login from SSH (ssh root@<BIFFERBOARD_IP>).

Before launching ser2net application make sure that your hardware is correctly connected:
Bifferboard Serial Port (RS232) <-> MAX3232 level adapter circuit or other <-> Serial Device (PC, Microcontroller, etc - In my case I used an old PSION Series 5 MX: http://www.botdream.com/blog/linksys-nslu2-network-storage-link-for-usb-20-disk-drives/#2.3)

From Bifferboard SSH launch ser2net application to bridge BB Serial Port to Ethernet:
>ser2net

to termincate ser2net it is required to:
>ps

check ser2net PID

>kill -9 PID

Now that ser2net is running you will need to run netcat tool from a linux machine (or windows).
1st lets test if BB ser2net is ready for communication:

>nc -zvn <BIFFERBOARD_IP> 2005
It should respond with the following message: (UNKNOWN) [192.168.1.66] 2005 (?) open

Connecting to BB ser2net interface:
>nc <BIFFERBOARD_IP> 2005

If you write something on netcat (from Linux machine) it shoud appear on your Serial Device.
Also, if you write something on your Serial Device it should appear on your Linux machine netcat application!

This works both ways for the same TCP/IP connection (it is possible to send and receive data from the same netcat connection).

Tests Work flow



Test from Linux PC: Connecting netcat to Bifferboard (Sending and receiving data)


Bifferboard


Max3232 Voltage Level Converter (3.3VDC to RS232)


Psion - Serial Device

3) Splitting netcat console into 2 additional commands

The previous test only allowed to send and receive data from the same console (same netcat instance). The following commands will split Data Input and Output into 2 separated consoles:
(bifferboard IP is 192.168.1.66 and ser2net is listening on port 2005)

From a Linux desktop computer open 3 consoles and run the following commands:

// Console 1:
>nc -lp 7777

// Console 2:
>nc -lp 7778

// Console 0:
>nc 127.0.0.1 7777 | nc 192.168.1.66 2005 | nc 127.0.0.1 7778

Writing to console 1 will redirect data to Serial Device and writing from Serial Device will redirect data to console 2.
Console 0 will make the main netcat connection to bifferboard ser2net and split data in and out to the other consoles via extra netcat connections.
(Beware when using netcat in listen mode, your security may be compromised)

4) Connect 2 Bifferboards over TCP/IP to bridge 2 Serial devices

We are now able to convert 1 serial device into a TCP/IP interface, nothing to special that can not be implemented with dedicated hardware, but how about connecting 2 serial devices together through a TCP/IP network? Just imagine that you have some serial logging device with RS232 connection and you require a PC with proprietary software to log data, every time that you need to take the serial device to a different place you also require the PC, that can be a very annoying. If you use 2 bifferboards to bridge RS232 through TCP/IP there is no more need to carry around the PC, as long has Network connectivity is available. If not, there are also some nice equipment that bridge Ethernet over wireless or probably one could try some USB Wireless dongle on bifferboard! Imagine now that you need to take the same serial device to some remote place and luckly you have some Broadband Internet connection (haven't tested this, but if broadband connection is fast enought with reduced latency response it should work fine).

This should be easy to implement, just required to have 2 bifferboards + 2 USB Pen Drives + 2 Voltage Level Adapters (MAX3232) and follow the above steps (until point 2) for both bifferboards (imagine them as twin boards). For the example bifferboard1 IP address is 192.168.1.66 and bifferboard2 IP address is 192.168.1.77. Since both boards will have the ser2net application listening on port 2005 it is required some extra functionality to bind them together, that can be done using a similar mechanism used in point 3:

note1: after launching ser2net application in both bifferboard1 and bifferboard2
note2: bifferboard1 must be initialized first

- bifferboard1 (192.168.1.66 - the listener board)

// bb1 input   | ser2net in/out       | bb1 ouptut
>nc -lp 2000 | nc 127.0.0.1 2005 | nc -lp 2010

- bifferboard2 (192.168.1.77 - the connecter board)

// bb2 input <- bb1 out | ser2net in/out        | bb2 output -> bb1 in
>nc 192.168.1.66 2010 | nc 127.0.0.1 2005 | nc 192.168.1.66 2000


// NN
Comments