For the past 10 years or so of my career, I’ve mostly been employed as a sysadmin. During this time, I spend a great deal of time working with Solaris 10. Solaris 10 has a command called tip. Tip can be used for basic serial communications. You basically just pass it a baud rate, and a serial device, and it connects the STDIN and STDOUT.
Working with Arduino, sometimes you want to connect to the serial port and communicate with it. There is a whole Serial library for reading from and writing to Arduino via the usb cable. The Arduino IDE also comes with a serial monitor for use. However, using NetBeans, I find it kind of silly opening Arduino IDE just to use the serial monitor. Unfortunately, tip seems to be a Solaris-only utility. At a loss, I turned to google.
Google Proves Unhelpful
Shocking, I know. The number one solution to this is “Well, just write something in C!” I know what you’re thinking, and yes it did occur to me that this would be right up my alley. However, I know there is a utility that exists that does exactly what I want. In the interest of not re-inventing the wheel, I search on. The number two solution to the problem is a program called Minicom. Minicom is a fairly heavy menu-driven program that does serial comms. From what I can tell, it seems to be more like Microsoft’s Hyper Terminal than tip. Since I’m just looking for a simple command line utility, I move on.
Finally, after much searching, I come across my solution. There is a program called cu that seems to function exactly like tip. It even share the same disconnect code: ~. to hang up a connection. Even better: it’s in the repositories!
On an Ubuntu system, all you need to do is:
sudo apt-get install cu
…and you’re good to go. To connect is simple, just enter:
cu -l /dev/ttyWHATEVER -s BAUD_RATE
…and you’ll connect to your Arduino. To hang up, just enter ~. and it will disconnect (Ctrl+C and Ctrl+D have no effect).
After spending some time using Eclipse and Arduino IDE for Arduino development, I’ve decided enough is enough! No longer will I put up with the unbearable hardship of using some other IDE. It’s NetBeans or bust! Well, it was a long road, but I’ve made it. If you’d like to make it too, then I can help.
First, we need to install the Arduino IDE. On Ubuntu, this is a simple apt-get:
sudo apt-get install arduino arduino-core gdb-avr
When that is finished, run the Arduino IDE.
Click Add when prompted about Dialout permissions
Enter your password
Before we can continue, we must logout, then log back in for the updated permissions to take effect.
Verify it works
Open Arduino IDE
Click File -> Examples -> 01.Basics -> Blink
A new window should launch with code for the basic blink program.
Plug your Arduino Uno into your computer via usb port. Click Tools -> Serial Port and select the correct Serial port
Click the Upload button on the toolbar. If all is well, your Pin 13 LED should start blinking.
Click Tools -> Options
Click on the C/C++ tab
In the bottom left corner, click Add…
In the Base Directory: field, enter the location of your AVR tool collection. apt-get put mine at /usr/bin
In the Tool Collection Family: dropdown, select GNU
In the Tool Collection Name: field, enter Arduino. Click OK when done
The various commands will be populated with the standard GNU toolkit commands. This is not what we want. Change them all to their avr equivalents: avr-gcc, avr-g++, avr-as, and avr-gdb. There is no avr-make, so leave it as the standard make. Feel free to clear the QMake Command: field.
Click the Code Assistance tab. Ensure the Tool Collection: dropdown has your Arduino toolchain selected and that the C Compiler tab is selected
Add arduino libraries. These are:
/usr/share/arduino/hardware/arduino/cores/arduino /usr/share/arduino/hardware/arduino/variants/[VARIANT] /usr/share/arduino/libraries
Click C++ Compiler. Add the same libraries as above
For our plugin, we’ll be using arduino-netbeans by Jaques Claudino
Click the above link, and navigate to Downloads. Download the latest Linux plugin.
When the download is completed, return to NetBeans.
Click Tools -> Plugins and click the Downloaded tab
Click Add Plugins…
Browse to the location of the downloaded plugin, select it, and click OK
Follow the wizard.
When prompted about an untrusted certificate, we might as well click Continue. After all, we are downloading software made by Some Guy, it’s not going to be signed by VeriSign or somesuch.
Click Finish when done.
Verify it works
Click File -> New Project…
Select Arduino and click Next >
Give your project a name, and click Finish.
First, open up the Makefile for your project, we have some changes to make
As the comments at the top of the Makefile say, we need to make some changes. First set COM_PORT to be the correct serial port.
Next Set ARDUINO_BASE_DIR to the correct installation path. For me, that is /usr/share/arduino
Next, uncomment the correct configuration. Since I am using an Uno, there is no change for me. However, if you have a different board, comment the Uno section and uncomment the correct board.
We should officially be set. In your main.cpp, implement the blink program. I recommend copying and pasting the one provided by Arduino IDE that we used previously. Be sure you don’t delete the #include and extern HardwareSerial Serial; lines.
When you are ready, click Clean and Build. Then click Run. If all is well, your onboard Pin 13 LED should blink.