R/C PIC Serial Interface for Linux

After my first attempt to interface my R/C transmitter with Linux I discovered the very nice and free FMS Flying Model Simulator.


The PIC interface contains a microcontroller that converts the impulses from the transmitter into a nice serial protocol. This has the benefit that it works reliably on any operating system without resorting to low-level hardware access and the requirement for non-interruptible services.

The model I have supports two different protocols:

Sync F0

The 'F0' protocol is running at 9600 bps. It supports 8 buttons and a varying number of channels:

Fn BB C0 C1 C2 C3 C4 C5 C6 C7 ...

The first byte 0xFn is a sync byte. The upper nibble is always 0xF and the lower nibble is the number of bytes in the packet including the sync byte. So for an 8-channel transmitter the sync byte is 0xFA i.e. sync + button + 8x data.

The second byte is reserved for buttons status. I've never seen a value other than 0x00 here but I suspect it's a simple bitmask so that there could be up to eight buttons.

The next bytes (up to the next sync byte) are the channel data. The max. data range I've seen so far is from 0x34 to 0x99 with the center at 0x70.

Sync FF

The 'FF' protocol is running at 19200 bps and supports a fixed number of 8 channels:

FF C0 C1 C2 C3 C4 C5 C6 C6 C7

The first byte 0xFF is the sync byte. The following eight bytes are the channel data.


For now I've attached the interface to my laptop using a keyspan USB-Serial adapter which works nicely under Linux. The data can be very easily read from the serial port so I haven't spent much time to develop a driver for that although it would probably be nice to make it appear as a regular joystick.

Dec 06 2003 Today I took some time to get to grips with the Linux event driver, serio interface and inputattach util. The module works OK so far when using the evdev interface but fails to show up as a regular joystick device (i.e. /dev/input/jsX). I've tested the setup with a Magellan SpaceMouse and it works so I'm absolutely puzzled why my module is acting up like this...

Dec 08 2003 A look into driver/input/joydev.c revealed that some conditions must be met for an input device to be recognized as a joystick. Namely it has to have buttons of a sort which my module didn't. Another thing I noticed is that it has no effect to alter the absmin and absmax values after input_register_device which is a pitty since it would be possible to calibrate the device on-the-fly. But it works!

The code is here for download. Use at your own risk as I won't accept any responsibility for fitness of purpose, correctness, damages to your equipment, etc.

Dec 26 2005 The above code does not compile with the 2.6.14 kernel I'm using andI currently don't have plans to update it. Just saying.


Last modified: Dec 26 2005
Copyright ©2002 Ulrich Hertlein