RamPi - Raspberry Pi Network Tool

The RamPi project is an embedded system made from a Raspberry Pi and LCD that can retrieve LLDP (Link Layer Discovery Protocol) information from neighboring devices on a network such as the system name and description, port name and description, VLAN names, and IP management address. In this tutorial we will go over the necessary steps to put together a RamPi system made up of the following parts:

1x Raspberry Pi 2 B (Or newer) + microSD memory card

https://www.amazon.com/Raspberry-Pi-Barebones-Kit-...

1 x Elecrow 5-inch TFT LCD HDMI Display

https://www.amazon.com/Elecrow-RPA05010R-800x480-...

1 x Shutdown circuit (use with button)

https://mausberry-circuits.myshopify.com/collectio...

1 x 3A UBEC (DC-DC voltage regulator)

https://www.amazon.com/gp/product/B01MUAGOAP/ref=o...

1 x Battery Charging module

https://www.amazon.com/Mobile-Battery-Charger-Modu...

4 x 18650 Batteries

https://www.amazon.com/Samsung-INR18650-25R-Rechar...

1 x Female Power Jack Socket

https://www.amazon.com/BestTong-DC-099-Female-Moun...

1 x Rocker Switch

https://www.amazon.com/DIYhz-Environmental-Protect...

2 x short micro USB cables

https://www.amazon.com/CableCreation-2-Pack-Degree...

cable connectors

https://www.amazon.com/eBoot-Connector-Female-Cabl...

YOU WILL NEED A SOLDERING IRON AND SOLDER!

Spool of 3-D printing filament to print an enclosure for the LLDPi *(You will need access to a 3-D printer)

11 x 1/4" machine screws (to hold everything in place)

microSD adapter to read/write from PC with Monitor, HDMI cable, Keyboard & Mouse to setup Raspberry Pi

Step 1: 3D Print Case

After you have found your favorite color of printing filament that is compatible with the 3-D printer you are going to use, then download these 4 files and start printing them.

Step 2: Install Raspbian on SD Card

You will need to have a firm understanding of Linux to be able to make a RamPi.

Go to the link below and download the latest version of Raspbian with Desktop.

https://www.raspberrypi.org/downloads/raspbian/

Use your computer to write the OS image onto the microSD card. Unzip the Raspbian file and go to the following link to view instructions specific to the OS you are currently using to install the image.

https://learn.sparkfun.com/tutorials/sd-cards-and-...

Now we should be able to plug the microSD card into the Raspberry Pi 3 and boot it up. Make sure the raspberry pi is hooked up to a monitor and keyboard and has an internet connection when going through this guide.

Step 3: Setup Raspbian on the Raspberry Pi

First we will make sure that the keyboard works properly by specifying which locale to use. Run the following command, where $ is the command line prompt, don't type it in.

$ sudo raspi-config

This should now take us to a screen where we can edit the Localisation Options, it should be the fourth on the list. Now we want to select Change Locale, go down the list and hit space bar on the locale named en_US.UTF-8 UTF-8 and set it to default on the next screen. We also need to change the timezone by going back into the Localisation Options and select Change Timezone and set it to America / Denver

Now we need to go into Boot Options, Desktop / CLIDesktop Autologin in order for the pi to autologin when booting up. Let's go into the Advanced Options and select Expand Filesystem to use the entire SDcard. We might also want to change the user password by selecting the first option, Change User Password. It is highly recommended to write the password down, don't forget it! The default password is raspberry. Then hit Finish to exit. The Raspberry Pi might need to reboot for the changes to take effect. Now open a terminal and run the following command and select this set of options when prompted,

$ sudo dpkg-reconfigure keyboard-configuration

Generic 105-Key (Intl) PC

Other ->then-> English (US)

The default for the keyboard layout

No compose key

No

Our next step is to update and upgrade Raspbian to the latest version. To do this simply open a terminal and type,

$ sudo apt-get -y update && sudo apt-get -y upgrade

If the last command doesn't finish properly or gives a message about a broken package, then we might need to reboot and re-run the command. Wait until that finishes running and then execute the following the commands,

$ sudo apt-get -y update

$ sudo apt-get install -y vim tshark tcpdump ethtool gawk

When asked "Should non-superusers be able to capture packets?", hit Yes.

Step 4: Configuring the LCD

The next steps will be to configure the LCD display to work with the Raspberry Pi. Turn off the Raspberry Pi, mount the LCD display and power it back on so that it matches the pictures above. Make sure the HDMI ports line up like shown in the picture and plug in the HDMI connector.

Next, we need to execute the following commands to download and install the driver for the LCD display.

$ git clone https://github.com/Elecrow-keen/Elecrow-LCD5.git

$ cd Elecrow-LCD5

$ sudo ./Elecrow-LCD5

and type y to reboot. After the device finishes rebooting, we will also need to make changes to the display orientation.

$ sudo vim /boot/config.txt

and look towards the end of a file for a line like

display_rotate=0

and change it to

display_rotate=3

Reboot the Raspberry Pi, wait until the Raspberry Pi boots up again and open up a terminal. And run the following command to install a way to calibrate the touch screen.

$ sudo reboot

$ sudo apt-get install -y xinput-calibrator xinput xserver-xorg-input-evdev

The X and Y axis of the touch screen need to be swapped so we execute the following commands to finish adjusting the screen.

$ xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axes Swap' 1

$ xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0 #################################################################

If there ARE errors after executing the commands above then you can try making these changes to the driver files used by the Raspberry Pi. Depending on which Raspberry Pi you are using for this LLDPi there might be some slight differences with setting up the LCD drivers and/or other settings. When setting this up with a Raspberry Pi 3, there was a problem with the LCD using the following config file

/usr/share/X11/xorg.conf.d/40-libinput.conf

When it should have been using this config file for another driver evdev

/usr/share/X11/xorg.conf.d/10-evdev.conf

To fix this run the following commands,

$ sudo mv /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf

$ sudo reboot

Then try running the commands to swap the X and Y axis again.

$ xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axes Swap' 1

$ xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0

If this still does not work then you will need to look for another way of getting the touchscreen configured properly.

###############################################################

If the commands DO work and the touchscreen works properly then proceed to edit the following file to have these 4 lines of code.
$ vim /home/pi/.config/lxsession/LXDE-pi/swapAxis.sh

#!/bin/bash

xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axes Swap' 1

xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0

exit 0


Don't forget to give the script the appropriate file permissions.
$ sudo chmod 755 /home/pi/.config/lxsession/LXDE-pi/swapAxis.sh

The next command will ensure the app starts and axis are swapped correctly every time the Pi boots up.

$ sudo vim /home/pi/.config/lxsession/LXDE-pi/autostart

Append the following 2 lines,

@/home/pi/.config/lxsession/LXDE-pi/swapAxis.sh

@lxterminal

Step 5: Build the Circuit...

Get the soldering iron ready, grab the cable connectors, and begin building the circuit that will allow the 18650 batteries to power the RamPi. Start with the female power jack socket and solder some cable connectors to attach it to the input end of the UBEC. Then we need to get a male micro usb cable and have it attached to the other end of the UBEC like shown in the picture. The UBEC should have the pin set how it is shown in the close up picture. Then grab the set of 18650 batteries, connect them in parallel and solder a cable connector ready to connect to the battery charging module. Arrange what you have made so far of the circuit into the case along with the batteries.

Step 6: Put It All Together...

Now screw the battery cover on to the case. The battery charging module should have the UBEC connected through the micro USB, and the batteries on the other side through a pair of cable connectors. The other USB cable on the battery charging module will lead to the shutdown circuit. Get the rocker switch prepared with a cable connector that'll be paired to the shutdown circuit. The shutdown circuit will also have 2 other wires to the raspberry pi for signaling a shutdown sequence, as well as supply power through the other larger USB to the raspberry pi, as shown in the last couple pictures. The larger USB being used in the picture is needed because it supplies 2.1 amps while the other only supplies 1 amp.

Follow this link to get directions on setting up software and hardware to give the raspberry pi a graceful shutdown switch.

https://mausberry-circuits.myshopify.com/pages/set...

After getting everything setup for the graceful shutdown circuit, make sure you slide the rocker switch into the slot on the side of the case before securing the raspberry pi down with screws, then fit everything into the case ready to add the already-working LCD and put the cover on the case with the screws.

Step 7: Coding the LLDPi Application

Now that we have configured the hardware we can proceed to work out the code that will create a GUI and gather all the information we need. The files with the code necessary for this application are located at the bottom of the page. You should download them and make sure they are in their correct respective directory paths, as shown below. Make sure to change the file names with a .txt extension to a .sh extension.

$ mkdir /home/pi/LLDPi

$ cd /home/pi/LLDPi

$ touch /home/pi/LLDPi/lldp.sh

$ touch /home/pi/LLDPi/getSWITCHinfo.sh

$ touch /home/pi/LLDPi/getVLANinfo.sh

$ touch /home/pi/LLDPi/LLDPiGUI.py

$ touch /home/pi/LLDPi/reset.sh

***Might need to run this to make the scripts above executable

$ chmod 755 filename

$ touch tshark.cap

$ sudo chown root:root tshark.cap

$ touch tcpdump.cap

$ touch displayLLDP.txt

$ touch progess

----------------------------------------------------------------------------

[Optional] This will make a convenient icon at the Desktop screen that the user can double-click to start the LLDPi Application. Edit the following file to create the icon and make sure it has the following contents.

$ vim /home/pi/Desktop/LLDPi.desktop

[Desktop Entry]

Name=LLDPi

Comment=RUN LLDPi Script

Exec=/home/pi/LLDPi/LLDPiGUI.py

Terminal=true

Type=Application

*If you have a picture to use as an icon then add a line to the LLDPi.desktop file that reflects the directory path to the picture,

Icon=/absolute/path/to/picture/file

----------------------------------------------------------------------------

Give the scripts a test run by checking the output of ./LLDPiGUI.py or by clicking the icon on the main screen

$ vim ~/.bashrc

Add a line like the one below at the end of ~/.bashrc to start the LLDPi app at boot time. /home/pi/LLDPi/LLDPiGUI.py

And that should be it, the LLDPi should be complete and ready to try out.

Share

    Recommendations

    • Safe and Secure Challenge

      Safe and Secure Challenge
    • Faux-Real Contest

      Faux-Real Contest
    • Warm and Fuzzy Contest

      Warm and Fuzzy Contest

    Discussions

    0
    None
    slowthumbs

    Question 5 months ago

    Can the files for step 5 be re-posted? The only one that's available for download in the LLDPPiGUI python script, the rest come back 403 forbidden.