MNU code and package used from the community - Saultes45/Bathymetry GitHub Wiki
Content
- RTKlib for Linux
- Berryboot or NOOB(stretch)
- CRC32
- Wlan0 up on boot
- Automount volumes
- Persistent tty devices name
- RPi as Access Point (AP)
- IMU
- Script @ boot
- 3G module Huawei (E303h-2)
- Dropbox for RPi
- Question and read answer in shell scripts
Create a script that waits for user input
#!/bin/bash
read -p " Press any key to continue..." -n1 -s -e
don't forget the chmod +x
and run with ./mybootscript.sh
Pip upgrade all packages
import pkg_resources
from subprocess import call
packages = [dist.project_name for dist in pkg_resources.working_set]
call("pip install --upgrade " + ' '.join(packages), shell=True)
Change default web browser
For, example Dillo is a minimal preinstalled one:
sudo update-alternatives --config x-www-browser
SSH welcome screen
Change the SSH Login Message https://www.daveperrett.com/articles/2007/03/27/change-the-ssh-login-message/
sudo vi /etc/ssh/sshd_config
sudo vi /etc/ssh/sshd_config
sudo vi /etc/banner
#screen not install in a basic Debian package
quit screen session: ctrl a --> K uppercase --> y
Open a new terminal window from shell
lxterminal with argument
#Shortcuts in
lxterminal 0.2.0-1 (vivid) has a property tab for shortcuts.
In previous versions, there is no such possibility. I also tried to use the configuration of the newer version with the older version. It does not work.
Start the terminal:
- Click Edit > Preferences
- Select the Shortcuts tab
- Make your changes
Festo PLC
Need to connect via FTP?
https://www.festo.com/net/SupportPortal/Files/430987/Boot%20Application%20loading%20without%20CoDeSys%20(V3.5)%20.pdf https://www.festo.com/net/SupportPortal/Files/450143/How_to_use_FTP_and_TFTP.pdf
Device | Default IP address
CPX-CEC | 192.168.2.50
CECC-X-... | 192.168.4.2
CECC-S/D/LK | 192.168.2.20
Static IP
https://www.modmypi.com/blog/how-to-give-your-raspberry-pi-a-static-ip-address-update
interface eth0
static ip_address=192.168.0.10/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
interface wlan0
static ip_address=192.168.0.200/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
netcat
sudo apt-get install socat
https://www.cyberciti.biz/faq/linux-unix-tcp-port-forwarding/
while true; do
socat tcp-listen:54321,reuseaddr /dev/ttyUSB0,b115200,raw,echo=0
done
RTKlib for Linux
normal
git clone https://github.com/tomojitakasu/RTKLIB.git
https://gnss.co/2014/07/17/rtklib-on-raspberry-pi/
plus demo5 from RTK explorer
http://rtkexplorer.com/downloads/rtklib-code/
Berryboot or NOOB(stretch)
berryboot (quadcore for new HW)
No need for any software
- https://www.howtogeek.com/170794/ask-htg-how-can-i-reclaim-the-full-capacity-of-an-sd-card/
- https://www.berryterminal.com/doku.php/berryboot
diskpart
list disk
select disk #
clean
Now check and Disk Manager
format as FAT32 (quick)
CRC32
sudo apt-get install libarchive-zip-perl
Automount volumes
Mounting volumes at startup (shell don't work even as sudo)
https://www.raspberrypi.org/forums/viewtopic.php?t=91677
sudo nano ~/.config/pcmanfm/LXDE-pi/pcmanfm.conf
go to the section called [volumes]
or via desktop by going to [file organizer], edit [preferences], [volume management]
Wifi - bring wlan0 up on boot
I changed auto to allow-hotplug for wlan0 in my /etc/network/interfaces, see below:
sudo hciconfig wlan0 down
pi@raspbmc:~$ cat /etc/network/interfaces
#auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Persistent tty devices name
To find data about your devices
lsusb
You should see something like:
dlinano@jetson-nano:/dev$ lsusb Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp. Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 8087:0a2b Intel Corp. Bus 001 Device 009: ID 413c:2110 Dell Computer Corp. Bus 001 Device 007: ID 413c:1010 Dell Computer Corp. Bus 001 Device 006: ID 0461:4d15 Primax Electronics, Ltd Dell Optical Mouse Bus 001 Device 008: ID 2563:0526
Bus 001 Device 004: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light Bus 001 Device 002: ID 0bda:5411 Realtek Semiconductor Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
THEN YOU CAN TRY something like that on different usb ports:
udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB1) | grep idProduct
And just replace /dev/ttyUSB0
by anything you think is your device tty
If the is a device at this tty, you will see somthing like:
udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0) | grep idProduct ATTRS{idProduct}=="ea60" ATTRS{idProduct}=="5411" ATTRS{idProduct}=="0002"
else you will see something like:
dlinano@jetson-nano:/dev$ udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0) | grep idProduct device node not found info: option requires an argument -- 'p'
to make sure you get the correct serial port, just read from it (that is if the device is continuously sending and is not waiting for data like while(!Serial.available())) For example to read from ttyUSB0:
cat /dev/ttyS0
If really you want to be fancy, you could use screen (you may have to install it)
sudo apt-get install screen
or even better, minicom (terminal interface)
sudo apt-get install minicom
You NEED to be sudo for setting the config file
To run: dlinano@jetson-nano:/dev$ sudo minicom -s
To exit: then Ctrl + A
, Q
And try:
cd ~/RTKLIB/app/str2str/gcc
sudo ./str2str -in serial://ttyUSB0#ubx -out tcpsvr://:9000#rtcm3
There is no possibility to have a file INI to it but you can check the list of parameters by using:
./str2str -h
Use the option -msg to specify the output RTCM messages.
But wait, there is a possibility to use ini
or conf
files for rtksrv
with the -o
option. Also there a a ton of already made conf files.
for better exmples of conf files, just follow:
For linux, only thoses CUI are available
./rtkrcv RTKRCV (CUI) * ./rnx2rtkp RNX2RTKP (CUI) * ./pos2kml POS2KML (CUI) * ./convbin CONVBIN (CUI) * ./str2str STR2STR (CUI) *
For example to find the idProduct of ttyUSB1
udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB1) | grep idProduct
Now edit the rule file AS SUDO
cd /etc/udev/rules.d
sudo nano ydnu.rules
ATTRS{idVendor}=="0483" ATTRS{idProduct}=="a217" ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="10c4" ATTRS{idProduct}=="ea60" ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="0403" ATTRS{idProduct}=="6001" ENV{ID_MM_DEVICE_IGNORE}="1"
Now edit the 99-com file AS SUDO
sudo nano 99-com.rules
(I saved this file (and the others as well) here just in case: My Dropbox
--> @ the beginning of the file: NO PASTE, EDIT
SUBSYSTEM=="input", GROUP="input", MODE="0660"
SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660"
SUBSYSTEM=="spidev", GROUP="spi", MODE="0660"
--> @ the end of the file: APPEND
SUBSYSTEM=="tty", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="a217", ATTRS{serial}=="00400024", SYMLINK+="sonar"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AL01BW1G", SYMLINK+="RFBS"
GPS as Ublox via adafruit USB to serial adaptor:
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="0001" , SYMLINK+="GPS"
GPS as Skytraq via its own USB to serial adaptor(soldered on the breakout board):
SUBSYSTEM=="tty", ATTRS{idVendor}=="", ATTRS{idProduct}=="", ATTRS{serial}=="" , SYMLINK+="GPS"
CRC32, command not found when autostart @ boot:
Shell check if file is present:
#!/bin/bash
file="/etc/hosts"
if [ -f "$file" ]
then
echo "$file found."
else
echo "$file not found."
fi
Only on LXDE desktop:
nano etc/xdg/lxsession/LXDE/autostart
Add a line BEFORE @xscreensaver
@lxterminal --command "/home/pi/xxx.shl"
https://www.raspberrypi.org/forums/viewtopic.php?t=65607
Lxsession
Each line in ~/.config/lxsession/LXDE/autostart represents a command to be executed. If a line starts with @, and the command following it crashes, the command is automatically re-executed. For example:
~/.config/lxsession/LXDE/autostart
@lxterminal
@leafpad
RPi as Access Point (AP)
Creating a wifi for downloading the configuration file from BS to the USV when the distance is short Matlab files to generate config files and download them will be uploaded.
Links
good:
- https://howtoraspberrypi.com/create-a-wi-fi-hotspot-in-less-than-10-minutes-with-pi-raspberry/
- https://github.com/billz/raspap-webgui#manual-installation
can help:
- https://cdn-learn.adafruit.com/downloads/pdf/setting-up-a-raspberry-pi-as-a-wifi-access-point.pdf
- https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md
Commands
cd
sudo ifconfig wlan0 down
ifconfig
sudo ifconfig wlan0 up
ifconfig
sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf.sav
sudo cp /dev/null /etc/wpa_supplicant/wpa_supplicant.conf
BE sure to have an internet connection BEFORE this step.
If there is no output in the terminal then that means it didn't work.
AFTER the following step you should see a title in ascii art and some downloading taking place.
wget -q https://git.io/voEUQ -O /tmp/raspap && bash /tmp/raspap
Config
- IP address: 10.3.141.1
- Username: admin
- Password: same password as black laptop [default: secret]
- DHCP range: 10.3.141.50 to 10.3.141.255
- SSID: raspi-USV-letter [default: raspi-webgui]
- Password: same password as black laptop [default: ChangeMe]
Change some parameters:
http://10.3.141.1/index.php?page=hostapd_conf
Configure hotspot/
+-- Basic/
¦ +-- ..
¦ +-- SSID
¦
Also for the Matlab for the automated connect (w/ WIN7 configuration to internet profiles) click on that link: Github
IMU
URL
NO LIBRARY TO INSTALL
Make sure I2C is enabled (sudo raspi-config
)
Running on 3.3v
Connect accordingly. On RPI3revB, only got it working on **BCM numbering ** 2 and 3. (0 and 1 not working, have to investigate)
i2cdetect -y 1
You should see this:
- http://ozzmaker.com/python-code-for-berryimu-accelerometer-gyroscope-magnetometer-pressure-sensor/
- https://github.com/mwilliams03/BerryIMU
git clone http://github.com/mwilliams03/BerryIMU.git
and after download:
cd /home/pi/BerryIMU/python-BerryIMU-gryo-accel-compass-filters
Before startting the file, you need to modify the addresses for (MAG+ACC) and (GYR)
- open
LSM9DS0.py
- at the very top, edit:
LSM9DS0_MAG_ADDRESS = 0x1D LSM9DS0_ACC_ADDRESS = 0x1D LSM9DS0_GYR_ADDRESS = 0x6B
Dropbox
\RFUSV\USV
- IMU.y
- LSM9DS0.py
- LSM9DS1.py
Datalog @ boot (sonar and GNSS receiver)
URL
Look at solution 1 (on 3): every time you log in: https://raspberrypi.stackexchange.com/questions/8734/execute-script-on-start-up
commands (this is not mine, I just pasted it from the forum): `cd ~
sudo nano superscript
sudo nano .bashrc
./superscript (add @ the end , append)
touch /home/pi/Desktop/EnableSuperScript.txt`
Dropbox
\RFUSV\USV
- killScreenAfter5s.sh
- LogGNSSData.sh
- LogSonarData.sh
Check before use:
sudo chmod +x yyyyyyy.sh
- path to the different files
- name of the tty devices
\Data from sonar test\combined\
superscript
3G module Huawei (E303h-2)
Status Led
Indicator: It indicates the status of the USB Stick.
- Green, blinking twice every 2s The USB Stick is powered on.
- Green, blinking once every 2s The USB Stick is registering with a 2G network.
- Blue, blinking once every 2s The USB Stick is registering with a 3G/3G+ network.
- Green, solid The USB Stick is connected to a 2G network.
- Blue, solid The USB Stick is connected to a 3G network.
- Cyan, solid The USB Stick is connected to a 3G+ network.
- Off The USB Stick is removed.
Tuto
http://www.instructables.com/id/Raspberry-Pi-as-a-3g-Huawei-E303-wireless-Edima/ http://alexanderhoughton.co.uk/blog/guide-sending-an-sms-with-raspberry-pilinux-huawei-e303-mobile-dongle/ http://alexanderhoughton.co.uk/blog/guide-sending-an-sms-with-raspberry-pilinux-huawei-e303-mobile-dongle/
Spark
https://www.spark.co.nz/help/mobile/set-up/set-up-mobile/
Not sure but can help
https://shkspr.mobi/blog/2012/07/3g-internet-on-raspberry-pi-success/ http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=4&t=1734&start=15 https://www.raspberrypi.org/forums/viewtopic.php?t=80925
usb-switchmode
ppp
Sakis3g interactive
https://github.com/Trixarian/sakis3g-source
Choose Option 4. Office (oa.)
Dropbox for RPi
follow the directions @ this address
Use the following for python code: `from subprocess import call
Upload = "home/pi/Dropbox_Uploader/dropbox_uploader.sh upload path/to/file dropbox_filename"
call ([Upload], shell=True)`
Battery 18650 with RTC and UART
to get the shell
i2cdetect -y 1
sudo su
modprobe i2c-dev
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -r
hwclock -s
Minicom
minicom -s
ttyS0 9600
Esc two times
both switches on UP position (toward ON). Check red led on PC side wehen sending data
Shell user prompt y/n question
https://stackoverflow.com/questions/23202022/shell-user-prompt-y-n