Dec 01

Weddings & Music

I attended a wedding this past weekend, and of course there was a DJ there who played music.  He was perfectly alright, but it got me thinking a bit about the music that is played at weddings(specifically, the wedding reception).  There are a bunch of songs that seem to be played regularly, although the only one that I can think of right now is Cupid Shuffle.  I have not heard the Macarena at a wedding in quite a few years, I think that it was more popular in the late 90s/early 2000s.

And of course, for whatever reason, the final song always seems to be Don’t Stop Believing.  I’m not sure why.  Has anybody else seen this in their travels?  I’m curious to know if this is a widespread thing or not.

One thing that was cool though, was that when the DJ played Piano Man, we all got in a big circle around the bride and groom and sang it to them.

Nov 21

Gyrocopter Man

In the news this week, gyrocopter man, aka Douglas Hughes, pleaded guilty to the felony charge brought against him.  As you may recall, he piloted his gyrocopter onto the lawn of the Capitol in order to deliver mail protesting campaign finance.

Clearly, campaign finance is a problem.  The solution to which I don’t know and I’m not going to ruminate on it right now.

The amusing part (to me, at least) is at the end of the article:

Hughes’s other charges included operating without an aircraft registration, three misdemeanor counts of violating national defense airspace and one misdemeanor count of operating a vehicle falsely labeled as a postal carrier.

For some reason, this is just hilarious to me.  I can see why that is a misdemeanor, it’s just quite amusing to think of a gyrocopter as a means of delivering mail.  It did have the USPS logo on it though, so I suppose it was technically labeled as a postal carrier.

Aug 29

Simple JAX-RS example & Maven configuration

So I have been using JAX-RS for the past few months now, and it was a little confusing to get started with.  To fix that, I’ve created a simple project on github that contains a minimal configuration for Maven in order to get a war file and have Jersey be the JAX-RS provider.

The other reason to do this is because the Jersey documentation is not very clear as to what you have to pull in from Maven Central in order to actually use the dependencies in a program.  Turns out, it’s just a single dependency, but finding it and making sure that it works is another matter.

Lastly, I just came across this page, which also has some good JAX-RS examples.  I hope that they help somebody!

May 27

udev rules for multiple interfaces

I just had to write a udev rule for Linux to interpret between several different endpoints on a single cellular modem, specifically this modem.  This shows up in Linux as 5 ttyUSB ports.  In order to make sure that the ports do not change around on me, I checked the following with udevadm:

$ udevadm info -a -n /dev/ttyUSB1

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

 looking at device '/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.1/4-1.1:1.0/ttyUSB1/tty/ttyUSB1':
 KERNEL=="ttyUSB1"
 SUBSYSTEM=="tty"
 DRIVER==""

 looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.1/4-1.1:1.0/ttyUSB1':
 KERNELS=="ttyUSB1"
 SUBSYSTEMS=="usb-serial"
 DRIVERS=="option1"
 ATTRS{port_number}=="0"

 looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.1/4-1.1:1.0':
 KERNELS=="4-1.1:1.0"
 SUBSYSTEMS=="usb"
 DRIVERS=="option"
 ATTRS{bInterfaceClass}=="ff"
 ATTRS{bInterfaceSubClass}=="ff"
 ATTRS{bInterfaceProtocol}=="ff"
 ATTRS{bNumEndpoints}=="02"
 ATTRS{supports_autosuspend}=="1"
 ATTRS{bAlternateSetting}==" 0"
 ATTRS{bInterfaceNumber}=="00"

 looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.1':
 KERNELS=="4-1.1"
 SUBSYSTEMS=="usb"
 DRIVERS=="usb"
 ATTRS{bDeviceSubClass}=="00"
 ATTRS{bDeviceProtocol}=="00"
 ATTRS{devpath}=="1.1"
 ATTRS{idVendor}=="1bc7"
 ATTRS{speed}=="480"
 ATTRS{bNumInterfaces}==" 8"
 ATTRS{bConfigurationValue}=="1"
 ATTRS{bMaxPacketSize0}=="64"
 ATTRS{busnum}=="4"
 ATTRS{devnum}=="11"
 ATTRS{configuration}==""
 ATTRS{bMaxPower}=="500mA"
 ATTRS{authorized}=="1"
 ATTRS{bmAttributes}=="80"
 ATTRS{bNumConfigurations}=="1"
 ATTRS{maxchild}=="0"
 ATTRS{bcdDevice}=="0232"
 ATTRS{avoid_reset_quirk}=="0"
 ATTRS{quirks}=="0x0"
 ATTRS{serial}=="0123456789ABCDEF"
 ATTRS{version}==" 2.00"
 ATTRS{urbnum}=="194649"
 ATTRS{ltm_capable}=="no"
 ATTRS{manufacturer}=="Android"
 ATTRS{removable}=="unknown"
 ATTRS{idProduct}=="1201"
 ATTRS{bDeviceClass}=="00"
 ATTRS{product}=="Android"

 looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb4/4-1':
 KERNELS=="4-1"
 SUBSYSTEMS=="usb"
 DRIVERS=="usb"
 ATTRS{bDeviceSubClass}=="00"
 ATTRS{bDeviceProtocol}=="01"
 ATTRS{devpath}=="1"
 ATTRS{idVendor}=="8087"
 ATTRS{speed}=="480"
 ATTRS{bNumInterfaces}==" 1"
 ATTRS{bConfigurationValue}=="1"
 ATTRS{bMaxPacketSize0}=="64"
 ATTRS{busnum}=="4"
 ATTRS{devnum}=="2"
 ATTRS{configuration}==""
 ATTRS{bMaxPower}=="0mA"
 ATTRS{authorized}=="1"
 ATTRS{bmAttributes}=="e0"
 ATTRS{bNumConfigurations}=="1"
 ATTRS{maxchild}=="8"
 ATTRS{bcdDevice}=="0000"
 ATTRS{avoid_reset_quirk}=="0"
 ATTRS{quirks}=="0x0"
 ATTRS{version}==" 2.00"
 ATTRS{urbnum}=="204"
 ATTRS{ltm_capable}=="no"
 ATTRS{removable}=="unknown"
 ATTRS{idProduct}=="0024"
 ATTRS{bDeviceClass}=="09"

 looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb4':
 KERNELS=="usb4"
 SUBSYSTEMS=="usb"
 DRIVERS=="usb"
 ATTRS{bDeviceSubClass}=="00"
 ATTRS{bDeviceProtocol}=="00"
 ATTRS{devpath}=="0"
 ATTRS{idVendor}=="1d6b"
 ATTRS{speed}=="480"
 ATTRS{bNumInterfaces}==" 1"
 ATTRS{bConfigurationValue}=="1"
 ATTRS{bMaxPacketSize0}=="64"
 ATTRS{authorized_default}=="1"
 ATTRS{busnum}=="4"
 ATTRS{devnum}=="1"
 ATTRS{configuration}==""
 ATTRS{bMaxPower}=="0mA"
 ATTRS{authorized}=="1"
 ATTRS{bmAttributes}=="e0"
 ATTRS{bNumConfigurations}=="1"
 ATTRS{maxchild}=="2"
 ATTRS{bcdDevice}=="0316"
 ATTRS{avoid_reset_quirk}=="0"
 ATTRS{quirks}=="0x0"
 ATTRS{serial}=="0000:00:1d.0"
 ATTRS{version}==" 2.00"
 ATTRS{urbnum}=="24"
 ATTRS{ltm_capable}=="no"
 ATTRS{manufacturer}=="Linux 3.16.0-4-amd64 ehci_hcd"
 ATTRS{removable}=="unknown"
 ATTRS{idProduct}=="0002"
 ATTRS{bDeviceClass}=="09"
 ATTRS{product}=="EHCI Host Controller"

 looking at parent device '/devices/pci0000:00/0000:00:1d.0':
 KERNELS=="0000:00:1d.0"
 SUBSYSTEMS=="pci"
 DRIVERS=="ehci-pci"
 ATTRS{irq}=="23"
 ATTRS{subsystem_vendor}=="0x1458"
 ATTRS{broken_parity_status}=="0"
 ATTRS{class}=="0x0c0320"
 ATTRS{companion}==""
 ATTRS{driver_override}=="(null)"
 ATTRS{consistent_dma_mask_bits}=="32"
 ATTRS{dma_mask_bits}=="32"
 ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,000000ff"
 ATTRS{device}=="0x1c26"
 ATTRS{uframe_periodic_max}=="100"
 ATTRS{enable}=="1"
 ATTRS{msi_bus}==""
 ATTRS{local_cpulist}=="0-7"
 ATTRS{vendor}=="0x8086"
 ATTRS{subsystem_device}=="0x5006"
 ATTRS{numa_node}=="-1"
 ATTRS{d3cold_allowed}=="1"

 looking at parent device '/devices/pci0000:00':
 KERNELS=="pci0000:00"
 SUBSYSTEMS==""
 DRIVERS==""

After I got the info, I noticed that the one thing that was different between all of the ttyUSB devices was ATTRS{bInterfaceNumber}.  So, I wrote a rule that looked like this:

ATTRS{idProduct}=="1201", ATTRS{idVendor}=="1bc7", ATTRS{bInterfaceNumber}=="00", SYMLINK+="cellular_1"

However, this did not produce the expected result of a new symlink.  It appears as though you can’t get the udev information for a product/vendor and the interface number in the same rule.  However, there are environment variables that are set which you can use.  If you run udevadm test, you can see what exactly the environment variables are that are set:

$ udevadm test --action=add `udevadm info -q path -n /dev/ttyUSB1`

...skip a bunch of data...
ACTION=add
DEVLINKS=/dev/serial/by-id/usb-Android_Android_0123456789ABCDEF-if00-port0 /dev/serial/by-path/pci-0000:00:1d.0-usb-0:1.1:1.0-port0
DEVNAME=/dev/ttyUSB1
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.1/4-1.1:1.0/ttyUSB1/tty/ttyUSB1
ID_BUS=usb
ID_MODEL=Android
ID_MODEL_ENC=Android
ID_MODEL_ID=1201
ID_PATH=pci-0000:00:1d.0-usb-0:1.1:1.0
ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_1_1_0
ID_REVISION=0232
ID_SERIAL=Android_Android_0123456789ABCDEF
ID_SERIAL_SHORT=0123456789ABCDEF
ID_TYPE=generic
ID_USB_DRIVER=option
ID_USB_INTERFACES=:ffffff:ff4201:ff0000:080650:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Android
ID_VENDOR_ENC=Android
ID_VENDOR_FROM_DATABASE=Telit Wireless Solutions
ID_VENDOR_ID=1bc7
MAJOR=188
MINOR=1
SUBSYSTEM=tty
TAGS=:systemd:
USEC_INITIALIZED=91898933

These variables can also be used in udev rules to do differentiate between different devices.  The two that we are interested in are ID_VENDOR_ID and ID_MODEL_ID, as these correspond to ATTRS{idProduct} and ATTRS{idVendor}.  Our new rule becomes:

DRIVERS=="option", ATTRS{bInterfaceNumber}=="00", ENV{ID_MODEL_ID}=="1201", ENV{ID_VENDOR_ID}=="1bc7", SYMLINK+="cellular_1"

The DRIVERS part of the rule may not be strictly necessary, but it can’t hurt it.

May 19

Export Board from Altium for OSHPark

Here’s a quick guide on exporting a board from Altium Designer 14 to be made by OSHPark.

1. Go to Design -> Layer Stack Manager
2. Set your stackup to be this:

.LayerStackManager

This information was derived from this FAQ.
3. Go to Project -> Compile PCB Project.  Fix any errors that could cause a problem.
4. Go to File -> Fabrication Outputs -> Gerber Files
5. Under ‘General’, set the units to be ‘Inches’ and the Format to be ‘2:4’
6. Under ‘Layers’, select the following layers:

  • Top Overlay
  • Top Paste
  • Top Solder
  • Top Layer
  • Bottom Layer
  • Bottom Solder
  • Bottom Paste
  • Bottom Overlay
  • Mechanical 15(assuming that you have drawn your board outline on mechanical 15)

Now export, save as <projectname>.cam

7. Go to File -> Fabrication Outputs -> NC Drill.  Use the following settings:

  • Units: Inches
  • Format: 2:4
  • Leading/Trailing Zeros: Suprress trailing zeros
  • Coordinate Positions: Reference to relative origin
  • Other: Optimize change location commands

Save as <projectname>-NCDRILL.cam

8. With the NCDRILL.cam file selected, go to File->Export->SaveDrill.  Set the extension to be .xln

9. Go to your project folder, there should now be a sub-folder called ‘Project Outputs for <Project Name>’.  Grab the following files:

  • *.xln
  • *.GBL
  • *.GBO
  • *.GBP
  • *.GBS
  • *.GKO(re-name the .GM15 file to be .GKO)
  • *.GTL
  • *.GTO
  • *.GTP
  • *.GTS

Put these all into a .zip folder.

10. Upload the .zip folder to OSH Park.

11. Have fun!

Apr 23

WMP54G on Windows 7

So I just upgraded my computer today with an nVidia 970GTX so that I can play Grand Theft Auto V.  However, this caused two problems:

  1. I couldn’t fit the card into my case
  2. The new case had a different configuration, so I had to move my wireless card to a different PCI slot.

When that happened, Windows freaked out.  Completely lost its sense of drivers, so my wireless wasn’t working.  How to get it to work(note: this is from memory, some of this wording is not exact):

  1. Go to Device Manager
  2. Right-click on the network device, go to ‘Update Driver Software’
  3. Go to ‘Browse My computer’
  4. Click ‘Let me pick from already existing drivers’
  5. Go to ‘Network Devices’
  6. Scroll down to Ralink Technology
  7. Select the ‘Wireless LAN a/g PCI card’
  8. Install the drivers
  9. Get on the internet!

Now time for GTA V!

Feb 03

Web Design and Programmers

On a project at work, we’re starting into web development from being entirely desktop applications.  It’s a new thing to learn because of that.  We’re working with a contractor, who is creating the majority of the website for us.  He has suggested, and we have implemented, a REST-based service for sending data to and from the server.  Fortunately, making a REST-based web service in Java is very easy using Genson and JAX-RS.

However, this post is not about that.  It is about web technologies in general.  Originally, I spent a fair amount of time researching different web technologies that use Java as the backend, and I came up with a few such as JSP, JSF, as well as some frameworks, such as PrimeFaces.  We’re not using JSF technology at the moment, but that’s not really the point either.

There are a lot of different web technologies out there, and each has its own pros and cons.  My real question here is why do we treat web design as separate from programming the website?  While researching the advantages/disadvantages of a REST-only website, I came across this good post on programmers.SE about the pros and cons, which then led me to this interesting post about using tag libraries in web pages.  Essentially, what this boils down to is:

The benefit here is that web designers are supposed to be able to work with these tags, or at least that’s what they say. In practice, in all my years of software development and programming, I have yet to ever see this magical unicorn walk out of the shadows and into the sunlight.

My question here though is: why are we treating web development in a different light than we are treating desktop application development?

When developing a desktop application, generally the programmers are the people who create the design.  Even if somebody creates the design in a GUI designer, the programmer has to be involved in how to tie all the events together – they don’t exist in separate paradigms, which is what web technologies seem to do.

In fact, I make all of my Java GUIs by hand.  I have never made a QT gui by hand, but from the generated code that I have looked at it follows a very similar programming model(composite design pattern).  What exactly is preventing a web designer from doing code, and what is preventing a programmer from making a website?

It seems to me that this is not something where the programmer and the web designer are two different people.  What seems to be better would be to have people that can straddle both areas.  After all, we are generally not pigeon-holed into just one area.  If you work mostly on backend code, it is not unreasonable to also touch the GUI code at some point, so you must know how the GUIs are set-up.  But for web development, this seems to be just the opposite.

Perhaps what we need is a swing-like web framework that you don’t need to make any HTML files for, just create the entire website through code.  This sounds complicated, and I don’t know if it would solve the problem.

Jan 19

PIC32 and I2C

I’ve been struggling with Microchip’s plib library trying to get I2C working.  First, the example I2C code is horrible.  Second, I’m not even sure what sample hardware from Microchip actually uses it.  It’s just so confusing.

Anyway, there are a few things to note here about the I2C library and the quirks that it has:

  • Make sure that you have pull-up resistors on the I2C bus.  This was problem #1.
  • Make sure you configure all pins as digital, if they are analog pins.  This was problem #2.
  • There are two methods you need to acknowledge the I2C: I2CAcknowledgeByte and I2CByteWasAcknowledged.
  • When reading a byte from the bus when you are the master, you need to call I2CReceiverEnable for each byte that you need to get.

These functions are not very special; the problem is that they are poorly documented.  For the most part, the plib functions simply access the registers directly in memory and return an appropriate value after checking the bits that may be set as a side effect.  It’s not particularly hard, they are just oddly named often times.

Anyway, you can see more about this both here and… some other place on the Microchip forums, I can’t find it now.

Hope that helps.