Skip to main content

Posts

Serial Port Tricks

Bidirectional The Netcat program can shovel data bidirectionally to/from a serial port and over a network, which is very handy indeed. Set the serial port in raw mode and configure it: # stty -F /dev/ttyUSB0 raw # stty -F /dev/ttyUSB1 raw # stty -F /dev/ttyUSB0 19200 # stty -F /dev/ttyUSB1 19200 Set up a netcat listener that will send data to/from the one serial device: # nc -l 1234 < /dev/ttyUSB1 >/dev/ttyUSB1 Set up a netcat client that will send data to/from the other serial device: # nc listeneripaddress 1234 < /dev/ttyUSB0 >/dev/ttyUSB0 Unidirectional For debugging and scripting, you can also use ordinary cat, echo, head or even data definition to access the serial ports:   Send data one way only using the common kitty: # cat /dev/ttyUSB0 > /dev/ttyUSB1 Send a message out a port using echo: # echo Hello > /dev/ttyUSB0 Send data denoted as hexadecimal values and suppress the LF at the end of the line: # echo -en "\x12\x23\x45...

dBm to Watt

I tend to forget some of the values and is too lazy to calculate it. dBm to Watt Conversion Table dBm Watts dBm Watts dBm Watts 0 1.0 mW 16 40 mW 32 1.6 W 1 1.3 mW 17 50 mW 33 2.0 W 2 1.6 mW 18 63 mW 34 2.5 W 3 2.0 mW ...

The Philosopher's Cross

While touring through Europe, I could not fail to notice all the various styles of crosses displayed everywhere on countless steeples and memorials.  Most are obviously decorous, but one or two depictions struck me as being functional - with an engraved scale - but for what purpose? Driving around in the green countryside of Bavaria, I thought of the various English proverbs: Crossed, Double Crossed, Nailing a Philosopher to His Own Cross. That last one made me think - a Philosopher's Cross - hmm... Until medieval times, any learned man was called a philosopher and good philosophers learned pretty much everything there was to be learned.  The information explosion and the necessary specialization is a recent thing.  Ancient philosophers learned about astronomy and navigation, in addition to classic literature, logic and mathematics.  Navigational Aids Knowledge of navigation was essential in ancient times not only for navigating at sea where the only featur...

Network Stress Testing

Stressing an Embedded Network Device Sometimes a new networked device behaves funny and you need to stress it to try and figure out where the bug is - firmware, hardware, software? If you feel like you need a big hammer to give the infernal device a good whack, then look no further - get nping , made by the friendly folks over at the nmap project. Get nping # yum install nmap While you are at it, you can also try another hammer called hping: # yum install hping3 Hammer it Now you can try hammering the device on its control port with good packets: $ nping -c 500000 --rate 10000 --tcp --data-length 1500 -g 2000 -p 2000 192.168.111.4   and with bad packets: $ nping -badsum-ip -c 500000 --rate 10000 --tcp --data-length 1500 -g 2000 -p 2000 192.168.111.4 And hopefully, that will cause the device to splutter and squeal and show you where the problem lies.  Even if it doesn't show you anything, hammering it will likely release some stress and ...

Packet Sniffing

A Transparent Bridge It is sometimes necessary to capture packets on a network in order to see why a certain host or device is misbehaving. Depending on the setup, you could use Ettercap and ARP table spoofing to reroute interesting traffic to your test machine as described in another post, but usually it is best to physically insert the test machine between the unit under test and the ethernet switch as a transparent bridge and then capture or save the data using tcpdump or wireshark . If your test machine is a laptop computer, then it likely has only one ethernet port.  You can add a second one using either a cardbus or USB ethernet adaptor. Install the ethernet bridge utilities and create a transparent bridge br0 , then assign the two ethernet ports to it (find their names with ifconfig ). Building the Bridge Here is a bridge script that I used recently: #! /bin/bash echo Configure a transparent bridge for Wireshark or tcpdump. killall NetworkManager # Install e...

Fedora Linux with Multiple Monitors

Quite annoyingly, a default install of Fedora with XFCE on a laptop computer doesn't support multiple monitors properly.  If you plug an external screen in, the only option is to mirror the main screen (using the function keys, fn-F3 or some such), which is seldom what I want.  I prefer having a bigger desktop stretched over both screens.  Even though the two may not have the same resolution, I think that it is a better use of pixels. Old Fashioned Setup Sometimes the prehistorical command line works best.  The two screens can be configured with xrandr , but one has to remember to rerun xrandr before the external screen is unplugged, to exclude it (turn it off).  It can be made more convenient by hooking two scripts to a pair of hot keys, which would bring your laptop machine back into this century. First you need to do some sleuthing.  Simply run xrandr with no parameters: $ xrandr Screen 0: minimum 320 x 200, current 1366 x 1536, maximum 8192...

Skyfall

The Church of Global Warming alarmists are getting really desperate.  They are now claiming with 95% certainty that human produced CO2 is causing catastrophic global warming and that it must be stopped at all costs, otherwise the sky will fall on our heads tomorrow.  Humanity needs to extinguish all organic power stations and go back to shivering in caves to prevent further warming... Warming, What Warming? Unfortunately for the alarmists, reality just flat out refuses to play ball and back them up.  For the past 15 years, despite us having emitted massively more organic gasses than ever before, the earth simply refused to warm up.  How many more years of contradicting data will it take to make the Church of Global Warming prophets admit that their computer models are maybe just a wee little bit off kilter?  Could it be that there are lots of green things out there that love to breathe CO2? Global Cooling Anyone over 50 is old enough to remember their pr...