OnlineCourse/UartComm (2004-11-11 20:12:56)

Information for developers about comm.c and related code

Read comm.c comments.

comm.c uses a buffer of commands to be sent out via serial port, and another buffer for the incoming bytes.

The buffer of "commands" contains struct cmd_queue_t elements, see comm.h, so they point to a function that will be called every time when a character can be written to the empty transmit buffer: for example when megatune requests the 22 byte datastructure (classical 'A' megatune command) uint8_t MTsendRTvar(uint8_t i) will be called with parameter 0,1,2,...21 respectively, and will return the megatune compatible byte-value (sometimes it needs small conversion, in the case msavr has different - eg. more precise - internal format). It's that simple.

The private is a pass-on value that is specified from pushfuncpar() and the function cmd_queue_t points to can use it whatever he wants. Private is mostly used to store pointer to string. TableDump() and ConfigDump() are a bit special, since they play a bit with the private and len variables. First see the table and config that they print (InitialConfig) and you will understand why it's done that way. Btw. it's very efficient.


More UART channels should be relatively easy to add. This brings up a small architectural question. We have a 2nd UART on AfreshBoard and all the future boards, so software must support it. It will be the 3d input via msavr can be controlled or configured (even simultaneously, see GenBoard/MenuSystem !).

Unfortunately comm.c is a little mix:

For making the 2nd UART work, you need:

and directly writes to UART1.

Model of megatune protocol

MembersPage/MichaelKristensen implemented an almost complete model of the MegaTune protocol in bin/emu_genboard.pl (yes, in perl, it runs on linux or win32 PC and acts as if it was a GenBoard).


There should be a separate page to CAN (page-name?), which is planned. See: http://www.can.bosch.com/content/Literature.html