Guys, this post is going to be fun. Like, a lot of fun.
If you have read the past logs you know that I include a UART interface for input-output with a host computer. This host can contain software to assemble or disassemble code, and whatever fancy softwary stuff you dare program.
But what if (what if ?) you could actually directly send commands to the board without a fancy software package that runs a GUI in your browser ? Who has the time to develop a GUI these days anyway ?
The word for the magic feature is "console".
Let's look at the setup:
- The Discrete YASEP is complete and working
- It provides an asynchronous seria port (115200bps)
- The serial port is connected to a USB-serial converter dongle
- That USB dongle is connected to your POSIX compatible computer, hopefully loaded with basic GNU packages.
- You open a terminal with a bash shell and can send and receive data through /dev/ttyS0 for example.
Now it becomes easy to control the board with a few keystrokes, just type "cat > /dev/ttyS0" !
But what keystrokes ?
ASCII codes for letter 0 to 9 map to 0x30-0x39 so we can directly extract the lower nibble but the letters A to F map to something totally different ! Why don't I code in octal, why ?
From here, I see where this could be going to : write software. But wait! If you got POSIX, you got tr !
[yg@localhost]$ man tr NAME tr - translate or delete characters SYNOPSIS tr [OPTION]... SET1 [SET2] DESCRIPTION Translate, squeeze, and/or delete characters from standard input, writing to standard output.Why write a program when you can use an existing filter ?
[yg@localhost]$ tr a-z A-z plop PLOP
The rest is pretty easy!
[yg@localhost]$ tr A-Fa-f '\072\073\074\075\076\077\072\073\074\075\076\077' |od -w1 -t x1 0123456789ABCDEF 0123456789abcdef 0000000 30 0000001 31 0000002 32 0000003 33 ... 0000010 38 0000011 39 0000012 3a 0000013 3b 0000014 3c 0000015 3d 0000016 3e 0000017 3f <-- yay ! 0000020 0a <-- new line 0000021 30 0000022 31 ... 0000031 38 0000032 39 0000033 3a <-- yay again ! 0000034 3b 0000035 3c 0000036 3d 0000037 3e 0000040 3f 0000041 0aThis can be saved as a script that you can invoke to send data to the board.
[yg@localhost]$ tr.sh > /dev/ttyS0 1234w 4WThis sends the value 0x1234 to the register R4. This supposes that
- 'w' is mapped to writing to the result data bus
- 'W' maps to writing the result bus address (and triggering a bus cycle)
- 'r' writes the register address of SI4
- 'R' writes the register address of SND
Unrecognised characters are discarded or ignored by the board. This is important because the terminal buffers lines, so you have to press the ENTER key to send the line over to the serial port.
Then you can save all these commands, copy, paste, translate, sed, hawk, python, perl, and maybe, at a higher level, interface with GDB ?...
This also removes the need to record keystrokes directly on the board for the purpose of replaying them later.