### ## ## ## ## ## ####
_ _ ( ) _ ( ) | | ( ) | | | | | | | | | (_/ \_) | `\___x___/'
### ## ### ## ## ## ## ## ## ## #### ###
##### ## #### ## #####
_____ |__ / / / / /_ /____|
IMPORTANT: enter the case-INsensitive alphabetic (no numbers) code AND WRITE SOME SHORT summary of changes (below) if you are saving changes. (not required for previewing changes). Wiki-spamming is not tolerated, will be removed, so it does NOT even show up in history. Spammers go away now. Visit Preferences to set your user name Summary of change: '''Information for developers about comm.c and related code''' Read comm.c comments. '''Incoming directions''' * interrupt fills comm_recbuf * vems.c regularly calls (from userspace) ringbuf_shift_proc(&menu_rs232, &comm_recbuf); * menu.c processes the incoming character. Depending on the state, might process it itself or pass the char over to ** comm.c ** sipr.c ** slcan.c (new) Some actions (either triggered by incoming data or automatically, eg. some periodic sending) generate '''outgoing packets'''. * Outgoing packets are queued in '''struct cmd_queue_t''' (comm.h) ** each point to '''a function that will be called for every outgoing character''' - with passed parameter increased each time * the actual buffer-producing happens in ringbuf.c ringbuf_fill(&comm_sndbuf) * that is called regularly from vems.c (userspace) For example when megatune requests the 48 byte datastructure (classical 'A' megatune command) uint8_t MTsendRTvar(uint8_t i) will be called with parameter 0,1,2,...47 respectively, and will return the megatune compatible byte-value. 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. SerialComm/SIPR heavily relies on private structures. ---- 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: * the underlying comm routines: irq handler, pushfuncpar() and friends * megatune compatibility * other routines, like printing mct and mcd on rs232 (any rs232port, since these are simple "char func(char) " functions) For making the 2nd UART work, you need: * copy the irq handler and make obvious changes and * either make pushfuncpar() parametrizable with the comm-port-selector (this would require to touch several files, sticking in the selector, I'd rather leave them alone) * or make a clone of pushfuncpar() that is parametrizable (I prefer this) or directly writes to UART1. ---- '''Model of megatune protocol''' Question: Is the perl emulator code available?? A: Probably still available, but not up to date and usable. Use a board for testing instead 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). * This havent been following development of comm.c and megatune ini files, as we found it simpler to use a board for testing anyway. ---- '''See also''' * http://sourceforge.net/projects/libserial/ is a project that helps serial communication over a POSIX system * CanBus Optional: Add document to category: Wiki formatting: * is Bullet list ** Bullet list subentry ... '''Bold''', ---- is horizontal ruler, <code> preformatted text... </code> See wiki editing HELP for tables and other formatting tips and tricks.