Category Archives: Embedded Systems

netgear router, no internet – reboot.

Script to check if the netgear router is working:

[root@srv01 ~]# crontab -l
#starta om netgear router om det är problems
*/15 * * * * /opt/scripts/reboot.sh >> /dev/null 2>&1

#!/bin/bash

ping 8.8.8.8 -c2

if [[ $? -gt 0 ]];
then

URL=$(curl -u USERNAME:PASSWORD "http://192.168.1.1/LAN_lan.htm" 2>&1 | grep 'method="POST"' | awk {'print $4'} | grep -oE "lan.*\"" | sed 's/"//g')
POSTDATA="device_name=WNR3500L&sysLANIPAddr1=192&sysLANIPAddr2=168&sysLANIPAddr3=1&sysLANIPAddr4=1&sysLANSubnetMask1=255&sysLANSubnetMask2=255&sysLANSubnetMask3=255&sysLANSubnetMask4=0&rip_direction=1&sysRIPVersion=Disabled&dhcp_server=dhcp_server&sysPoolStartingAddr4=100&sysPoolFinishAddr4=254&select=-1&action=Apply&lan_ipaddr=192.168.1.1&lan_netmask=255.255.255.0&rip_enable=0&rip_multicast=1&rip_version=2&lan_proto=dhcp&dhcp_start=192.168.1.100&dhcp_end=192.168.1.254&dhcp_start_old=192.168.1.100&dhcp_end_old=192.168.1.254&pptp_wan_ipaddr=...&l2tp_wan_ipaddr=...&pppoe_wan_ipaddr=...&pptp_serv_ipaddr=10.0.0.138&l2tp_serv_ipaddr=10.0.0.138&wan_proto=dhcp&wan_ipaddr=213.114.124.94&wan_netmask=255.255.240.0&repeater=0&repeater_an="

echo "need to restart the router..."
curl -u USERNAME:PASSWORD -d $POSTDATA http://192.168.1.1/$URL
EMAILMESSAGE="/tmp/emailmessage.txt"
echo "REBOOTED Router"> $EMAILMESSAGE
/bin/mail -s "Rebooted Router" "root@localhost" < $EMAILMESSAGE rm -rf $EMAILMESSAGE echo "$(date +'%Y-%m-%d %H:%M:%S') NEED TO REBOOT ROUTER!" >> /root/reboot.log
#echo "$(date +'%Y-%m-%d') NEED TO REBOOT ROUTER!" >> /root/reboot.log
else

echo "everything works..."

fi

Back to OpenBSD

I reinstalled my harddrive and installed OpenBSD once again.
After that I noticed that OpenBSD now supports tmpfs, so i mounted tmp and .cache directory in ram instead:

$ cat /etc/fstab
c62268885862ee35.b none swap sw
c62268885862ee35.a / ffs rw 1 1
c62268885862ee35.g /home ffs rw,nodev,nosuid,noatime 1 2
#c62268885862ee35.d /tmp ffs rw,nodev,nosuid,noatime 1 2
c62268885862ee35.f /usr ffs rw,nodev,noatime 1 2
c62268885862ee35.e /var ffs rw,nodev,nosuid,noatime 1 2
tmpfs /tmp tmpfs -m777,rw,nodev,nosuid,noatime 0 0
tmpfs /home/johan/.cache tmpfs rw,nodev,nosuid,noatime 0 0

Wpa_supplicant + FreeBSD + Eduroam

Download this: http://www.lan.kth.se/eduroam/AddTrust_External_CA_Root.pem

Edit wpa_supplicant.conf:

network={
ssid=”eduroam”
key_mgmt=WPA-EAP IEEE8021X
eap=TTLS
identity=”username@kth.se”
anonymous_identity=”username@kth.se”
password=”password”
ca_cert=”/usr/local/share/certs/eduroam.pem”
phase2=”auth=PAP”
}

Code for the project presentation

Code for the project presentation:



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#define TEXTER 4

char texten[TEXTER][255] = {
"Wake up, Matrix...",
"They are coming...",
"Follow the room edges...",
"Knock knock Matrix..."
};

int main(void){
int i,j = 0;
for(i=0;i < TEXTER;i++)
{
j = 0;
while(texten[i][j] != 0)
{
printf("%c", texten[i][j]);
fflush(stdout);
usleep(300000);
j++;
}
usleep(2000000);
printf("\n");
fflush(stdout);
}
}

}

OpenBSD gone, FreeBSD is my new laptop OS

I left the OpenBSD as a laptop project and installed FreeBSD instead.

The main thing that made me install FreeBSD instead of keep using OpenBSD is that i couldn’t use Matlab (this is used in my education) and Mplabx (which I use for programming PIC ciruits).

I installed virtualbox and installed ubuntu, and from there i installed both Mplabx and matlab with success.

If bhyve will come to OpenBSD, perhaps i can use USB passthrough and install a Linux machine from there and use X forwarding.

OpenBSD as a laptop

Im trying to get OpenBSD running as a laptop but there are some problems that i came across. The first one is OpenBSD x64 cannot run linux compability mode which makes it alot harder to use MatLab. Im thinking of running in under QEMU but i think that it will have worse performance though.

To compile projects with Arduino works good, its console based but i dont care about that. I will check if there is any possibility to use geany as an IDE for arduino.

I also want to be able to program microcontrollers, specificly the microchip controllers. I have bought an PICKIT3 and im trying to make it work under OpenBSD now. I noticed that QEMU does not support USB passthrough, that makes it alot harder to make it work though.

 

Lets see where it goes!