dsub: Serial Port class for C#.Net

dsub main formI’ve long held an affinity for serial ports. They’re easy to understand, easy to setup, and require no special drivers. I’ve worked on several projects over the years that have utilized serial ports, mostly in classic VB applications. Since learning Microsoft C#.Net, I’ve wanted to use it to interface with them. A few years ago I picked up a copy of Serial Port Complete Second Edition by Jan Axelson, and it’s been a tremendous help. Much of what I’ve learned has come from her book and website. I set out to develop my own serial port class based on my needs, and I’ve now finally finished it to the point where I feel comfortable sharing it. It’s called dsub, named for the D-subminiature electrical connector. I’m releasing it under an MIT license so you can download, use and modify the application and source code.

Download dsub here (Visual Studio 2010 project)

dsub uses .Net’s built-in SerialPort class, but adds some additional functionality to deal with multi-threading, error handling, etc. I won’t cover all the details of how it works, or why; for that, you should pick up a copy of Jan’s book and check out the COM_Port_Terminal application available on her website. dsub does differs in several ways from her serial port class, the most important difference being that I use the SerialPort.ReadLine method to get new data from the buffer. As a result, any serial port data that dsub reads will need a defined “end of transmission” character, such as a carriage return or line feed. This can be specified in dsub, so it’s possible to use any character. I did this because all the equipment I deal with sends data this way, and it’s easier to parse the data once I know the transmission is complete. If you have a situation where there isn’t a defined end of transmission character, then dsub won’t work. (Note: Jan’s class does not have this limitation.)

dsub Settings FormThe GUI application that’s included will read data from the selected serial port and display it in a grid. If a field delimiter is specified, it will use that to break up the data into separate columns in the grid. At the bottom of the screen, you can enter text to be sent. There is also a textbox where errors will be displayed. The application implements all the features of dsub so it provides a good example of how to use it.

If you use dsub in your application, let me know! I’d love to hear how it’s being used. I’ll also do my best to answer any questions or address any issues with it.

Install ntop on Ubuntu/Linux Mint

ntop graphIn a previous post, I wrote about how I setup a transparent bridge computer, which is able to monitor all network traffic passed through it. It works great, but to make it really useful, it needs some software that can report on the monitored network traffic in a useful manner. I decided to use ntop for this purpose, as it provides powerful reporting on bandwidth usage, which is exactly what I’m after. I’m not a regular Linux user, so I usually take the easy approach and install software through whatever GUI-based software manager is included. When I did this in Linux Mint however, I found the version available was not the latest, which is 5.0.1. I also learned that ntop has since been replaced by ntopng, which wasn’t available through the GUI. I’ve had some college courses in Linux/Unix administration, so I figured I could handle installing it “the hard way”. In this post, I’ll cover how I got ntop 5.0.1 running on my bridge computer.

(more…)

Creating a Transparent Bridge with Linux

Two Ethernet cablesI recently became interested in getting a better handle on bandwidth usage on our Internet connection at work. I wanted to see what I can do for free (or at least very cheap) so I started researching solutions using Linux. Before I can try out any software though, I need a computer that can do the monitoring. I decided to build a transparent bridge or “Machine-In-The-Middle”, which is a computer with two network interface cards (NICs) which are bridged together so that any traffic going to one card is passed through to the other. The bridge computer is installed in between two other nodes on the network, and any traffic passed through the bridged NICs can be monitored by the bridge computer. The bridge creates a slight delay, but is otherwise transparent to the nodes it is connected to.

Most of the information I used to guide me in setting this up came from Bridging Ethernet Connections at the Ubuntu community wiki and this page on how to setup a bridge in Debian from microHOWTO. I thought it might be pretty difficult, especially since I’m not a hardcore Linux guy, but I found it to be surprisingly easy. For the rest of this post, I’ll cover what I did to setup my transparent bridge computer.

(more…)

pc meter header

Analog PC Stats Meter

Intro

At some point while researching microcontroller projects, I came across several people who had used Arduinos and PICs to drive analog panel meters so they would display computer stats such as CPU load, memory usage, etc.  It immediately struck me as something I just had to do.  Here it is.  My PC meter uses an Arduino microcontroller and receives the stats from a .NET Framework application I wrote in C#.Net.  It’s housed in a plastic enclosure and looks quite professional IMHO.  It was a fun project, and something I think most any computer/electronics geek would enjoy.  I love mine, and I look forward to building more.

Here it is in action:

Read on for details on the parts and tools I used, some info on the process of building the device (and the problems I ran into) and links to download the source code and meter templates.

(more…)