Setup Menu Uses Text Editor Hack

Many embedded devices that require a setup menu will use a USB serial port which you connect to your favorite terminal emulator. But we recently encountered a generic USB knob that did setup using a text editor, like Notepad or even Vim (although that was a bit ugly). A company called iWit makes several kinds of USB knobs which end up in many such products.


These generic USB knobs are normally just plug-and-play, and are used to control your PC’s volume and muting. Some models, like the iWit, the user can configure the mapping within the device. For example, knob rotation can be set to generate up and down arrow keys, and knob press could be ENTER. One could do this kind of mapping on the PC, but many of these USB knobs can do it for you. The crux of the setup is this menu (which you can see in action in the first 30 seconds of the video below).



- WINDOWS MODE -
1 Clockwise : Up Key
2 Counterclockwise : Down Key
3 Press : Enter
4 Press+Clockwise : Next
5 Press+Counterclockwise : Previous
6 Long Press : Play/Pause
[RESTORE DEFAULT]
[SAVE & QUIT]

That’s nice, of course, but the surprising point is how the setup menu is implemented in the first place. The knob, already being an HID, spews forth the setup menu as if it were being typed from a keyboard. Turning the knob to select an option generates ANSI escape sequences for up and down cursor movement and somehow highlights the current line. Looking at the stream, you can see that the menus are proceeded with these codes:


ESC [ 4 ~ Private code?
ESC [ 1 ; 2 H Cursor row 1, col 2 ..

Support the originator by clicking the read the rest link below.