czwartek, 12 listopada 2015

Setting up proper terminal size for serial connection to an embedded device

console
When you work over serial line on an embedded device usually the terminal size it set to 80x25.

There's an easy way, however, to setup your real terminal size, just add the following line to your profile script (~/.profile):

resize > /tmp/resize
. /tmp/resize

resize command detects real terminal size and sets COLUMNS and ROWS parameters accordingly:

# resize
COLUMNS=159;LINES=52;export COLUMNS LINES;

One just need to execute the output as sh commands (using source "." command).

Conflicting DHCP server locator under Linux

cable-ethernet

In order to locate conflicting DHCP server in your LAN execute the following command:

sudo dhcpdump -i eth4 | awk '/IP:/{SRC=$2 " " $3} /OP:.*BOOTPREPLY/{ print "DHCP server found:", SRC; }'


The restart your PC network (use DHCP to get new IP). If you see more than one IP address here:

DHCP server found: 192.168.4.1 (0:9:6b:a3:fc:4a)
DHCP server found: 192.168.1.1 (f8:d1:11:9e:1d:8b)
DHCP server found: 192.168.4.1 (0:9:6b:a3:fc:4a)
DHCP server found: 192.168.1.1 (f8:d1:11:9e:1d:8b)
DHCP server found: 192.168.4.1 (0:9:6b:a3:fc:4a)

Then you have two, conflicting DHCP servers in your network. You can use http://www.coffer.com/mac_find/ tool to locate the device type that causes the problems.