Archive

Archive for July, 2015

Windows Text Console on SmartOS

July 23rd, 2015 Comments off

With SmartOS the vmadm console command offers a convenience method for pulling up a text console for a guest VM.  This is commonly used for Linux and BSD VMs and it can be enabled for Windows VMs too.  The below steps outline how to enable and utilize this feature on Windows 2012 R2 through the use of the Windows Emergency Management Services (EMS).

Configuration

  1. As an administrator user run the following commands. If you have configured more than one boot entry you may want to tailor this command to target only a specific boot entry.  Together these enable EMS and then set it to run on COM1 at a baud rate of 115,200.
    C:\>bcdedit /ems on
    C:\>bcdedit /emssettings EMSPORT:1 EMSBAUDRATE:115200
    
  2. From the SmartOS host start up the console and substitute in the appropriate UUID of the VM from vmadm list:
    # vmadm console <uuid>
    
  3. Reboot the VM.
  4. On the console window you will see something like the following:
    Computer is booting, SAC started and initialized.                               
                                                                                    
    Use the "ch -?" command for information about using channels.                   
    Use the "?" command for general help.                                           
                                                                                    
                                                                                    
    SAC>                                                                            
    EVENT: The CMD command is now available.                                        
    SAC>
    
  5. We’re at a SAC prompt, but it’s not yet the familiar CMD.EXE.  The SAC is the Special Administration Console which has some additional functionality, one of which is to start CMD.  To do so simple run cmd and then switch to the channel that it created:
    SAC>cmd
    The Command Prompt session was successfully launched.
    EVENT:   A new channel has been created.  Use "ch -?" for channel help.
    Channel: Cmd0001
    SAC>ch -si 1
    
  6. From here press any key and then enter in the username, domain, and password when prompted and CMD prompt will then be usable as well as PowerShell by running powershell at the CMD prompt:
    Microsoft Windows [Version 6.3.9600]                                            
    (c) 2013 Microsoft Corporation. All rights reserved.                            
                                                                                    
    C:\Windows\system32>

Limitations

This does not appear to work on all versions of Windows.  When I tried with Windows 7 the bcdedit commands completed successfully but the console text never appeared.  Older versions will need to use the bootcfg command instead of bcdedit.

While functional, the serial console can be a bit sluggish at times.  Also, when using this within xterm the text scrolls at the 25 line mark rather than filling up the full terminal window.

Tags: , ,

Electronic Gates for Wooden Trains

July 4th, 2015 Comments off


This morning I built the controller and software for the electronic gate system I’ve been working on for my sons’ wooden trains.  This brought interactive control to raising and lowering the gates through a web app.  The result:  it was a hit with my kids and they enjoyed it the rest of the day!

screenshot

Gates

The gates themselves are 3D printed gate housings with an SG90 9g RC servo that supports and opens the gate.  I designed these in OpenSCAD and printed them out on a Da Vinci 1.0 3D printer.  After printing the only assembly required was two screws to hold in the servo and the rest pushed together.  For the gate it is beneficial to leave it as a push-fit so that under abuse from the trains it will simply fall off rather than cause some component to break.

20150703_214603

20150703_215154

Controller Hardware

The parts for the controller are:

  • Raspberry Pi Model B – This is an older model and I’d recommend either the Model B+ or the Raspberry Pi 2 though the instructions will vary a bit from this page.
  • Adafruit Servo Hat – This plugs into the Raspberry Pi and allows for control of up to 16 RC servos.
  • Edimax EW-7811UN USB WiFi adapter – This is a common USB WiFi adapter for the Raspberry Pi.
  • 3 ft. Servo Extension Cables – The servo cables are quite short and these let them reach across the table.
  • 8 GB SD Card – An SD Card a few GB in size.  For a few dollars more you can get one double the size.
  • 2 5V power supplies around 1A.  I used an old phone charger with a Micro-USB connector for the Raspberry Pi and a separate power supply to connect to the Servo Hat.

The website for the Servo Hat includes a note:  “can be used with the Model A or B if you use a tall 2×13 header instead of the included 2×20″.  Another approach to getting this to fit on the Model B is to remove the component video output connector from the Raspberry Pi.  I clipped it off and connector (the yellow one) and the Servo Hat fit perfectly onto the board.  I also placed some electrical tape over the solder joints on the bottom side of the Servo Hat to prevent it from shorting out on the HDMI connector and capacitor on the Raspberry Pi board.

20150703_222854

When fully assembled it is about the size of a deck of playing cards:

20150703_214702

Base Install

The high level process for installing and prepping the base system is shown below which assumes some general familiarity with these systems and steps.

  1. Install Arch Linux.
  2. Connect the Raspberry Pi to a wired Ethernet connection.
  3. Run dhcpcd to acquire an IP address.
  4. Install packages for WiFi setup, I2C which is used to interface with the Servo Hat, and Python.
    pacman -Sy dialog wpa_supplicant i2c-tools python2-pip base-devel python2-flask
  5. Run wifi-menu to configure the WiFi.
  6. Edit /etc/wpa_supplicant/wpa_supplicant.conf to configure persistent WiFi security settings.
  7. Set the WiFi to be enabled at bootup.  Use the name provided when running wifi-menu, e.g.
    netctl enable wlan0-mynet
  8. Install the Python I2C libraries:
    pip2 install smbus-cffi
  9. Edit /etc/modules-load.d/raspberrypi.conf and add the two lines to enable I2C support:
    i2c-bcm2708
    i2c-dev
  10. Edit /boot/config.txt and uncomment device_tree_param=i2c_arm=on

At this point SSH should be working over WiFi into the Raspberry Pi.

Software

The control software provides the web front end and also the server-side code to control the servos.

The code is up on GitHub at:

https://github.com/edplese/gatecontroller

Once checked out and copied over to the Raspberry Pi it can be run with the following command which will start the server and listen on port 5000:

python2 main.py

The intent is that this is utilized through a tablet form factor but it works well also on other formats as well.

Closing Thoughts

I had also considered the ESP8266 WiFi module for this project in combination with the more generic Adafruit Servo Driver.  I opted for the Raspberry Pi due to the self-contained nature as the ESP8266 approach would have needed a separate system to run the web application.

Given that the Servo Hat can control 16 servos I am curious what other types of servo-controlled features would work well in this format.

Tags: