USB Serial

Serial port access can be very useful during embedded systems development.

I do most of my development on Mac OS X, or Ubuntu and Windows virtual machines. I use a USB to serial cable/breakout to connect a serial port to the Mac, which is then redirected by Parallels Desktop to the guest OS.

If you have a cable that uses the Prolific USB Serial chipset, getting up and running is well documented by Plugable. The driver they provide works for me. Most other cables use a chipset from FTDI, but Mac OS X already provides a driver for that.

To interact with a terminal on the embedded system you need some kind of terminal emulator.

I use and screen on Ubuntu -b 115200 /dev/ttyUSB0

Ensure that you have access to the device

sudo chmod 777 /dev/ttyUSB0

On Mac OS X I usually use screen

screen /dev/cu.usbserial 115200

USB CDC ACM driver for Windows

The LUFA library provides a template INF file that can be easily extended to create a serial port driver for your USB CDC ACM device. Here’s the template with CatalogFile added by me

;     Windows LUFA CDC ACM Setup File
; Copyright (c) 2000 Microsoft Corporation


Signature="$Windows NT$"

%MFGNAME%=DeviceList, NTx86, NTamd64, NTia64





AddService=usbser, 0x00000002, LowerFilter_Service_Inst


;  Vendor and Product ID Definitions
; When developing your USB device, the VID and PID used in the PC side
; application program and the firmware on the microcontroller must match.
; Modify the below line to use your VID and PID.  Use the format as shown below.
; Note: One INF file can be used for multiple devices with different VID and PIDs.
; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_2044

%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_2044

%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_2044

%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_2044

;  String Definitions
;Modify these strings to customize your device

Replace VID_03EB&PID_2044 with something appropriate for your device.

To use this on Windows 8.1 without disabling signed driver check, you’ll need to self-sign the driver. Install Windows Driver Kit (WDK) 8.1 and execute the following from a privileged command prompt

makecert.exe -r -pe -ss PrivateCertStore -n Test.cer

Inf2cat.exe /driver:. /os:7_x64,7_X86 

Signtool.exe sign /v /s PrivateCertStore /n /t "LUFA"

certmgr.exe /add Test.cer /s /r localMachine root

Note that in Windows Driver Kit 7.1 Signtool.exe is located under bin\selfsign, and in Windows Driver Kit 8.1 it is located under bin\x86

Now, you should be able to manually install the driver by pointing Windows 8.1 to the folder containing the INF and cat files.

Common audio format between Android and iOS

If you need a common audio format between Android and iOS, try AAC codec with container format MP4. The file extension used is mp4.

On Android, record using encoding MediaRecorder.AudioEncoder.AAC and container format MediaRecorder.OutputFormat.MPEG_4. That should play all right on iOS 7, or better.

On iOS, record using the following settings

NSDictionary *recordSettings = 
    [NSNumber numberWithFloat:44100.0],AVSampleRateKey,
    [NSNumber numberWithInt: 2],AVNumberOfChannelsKey,
    [NSNumber numberWithInt:16],AVLinearPCMBitDepthKey,
    [NSNumber numberWithBool:NO], AVLinearPCMIsBigEndianKey,
    [NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,
    [NSNumber numberWithBool:NO], AVLinearPCMIsFloatKey,

The resulting file should play all right on Android 4.3, or better.