The router is explained at the "Spacewire Router Manual":https://gmvmine.gmv.com/redmine-ad/attachments/download/44800/Spacewire%20Driver%20&%20Router.docx attached in this wiki page.
Spacewire Time Code
The time code concept is explained in this "link":http://spacewire.esa.int/content/Home/Time-Codes.php
All Spacewire configuration is done at _struct grspw_config dev_def_cfg_ at the *po_hi_driver_rasta_spacewire.c*
It includes the following for time code
.tc_cfg = TCOPTS_EN_TX|TCOPTS_EN_RX,/* Enable TimeCode */ .tc_isr_callback = app_tc_isr,/* TimeCode ISR */ .tc_isr_arg = NULL, /* No TimeCode ISR Argument */
Basically will only need o enable it to have it.
When a time code is received it will call the app_tc_isr callback, it is function declared further below that we can customize to further handle the time code. It has one parameter with integer time code value.
There is function to obtain current time code
*int router_get_tc(void *p, unsigned char *tc)*
Spacewire Plug and Play
The GR740 supports the Pnp protocol as states in its manual:http://www.gaisler.com/doc/gr740/GR740-UM-DS.pdf .
The manual provide a configuration port to apparently acesss the Pnp Register to know about the plugged in spacewire devices.
In terms of software PnP seems to be completely transparent to the user, the only detect code is a flag to inform user if HW supports the PnP:
In *void router_print_hwinfo(struct router_hw_info *hwinfo)*
printf(" Timers available: %s\n", hwinfo->pnp_avail ? "YES" : "NO");
SpaceWire Router in the N2X and GR740 voard
h2. Header duplication
Following what we think it's presumably the spacewire convention. It specifically says in the board data sheet that the message to be received at the end of the road, meaning when it reaches the final AMBA port, must have its header, however the router should be deleting the 1st byte of the header in the physical ports. This is achieved in the gaislersamples/router_demo by setting the 1st byte in the data field to have the last header byte.
In our device driver, since we know that we are receiving an iop_wrapper_t struct, that has a single buffer pointer to a buffer, and information about the header and payload offsets, we decrement the payload offset by 1, in order the contain the last header byte and increase the size by 1.
Gaisler has been contacted about the header duplication issue, below is the transcript of their feedback
bq. I'm not sure I understand your question but I will try to answer. The N2X has a router inside which is able to route based on logical addressing and/or path addressing. When header deletion is enabled (typically when path addressing) an "extra" byte is needed to select which port to route to/from within the N2X. If you configure the routing table to route incoming packets with node address X to AMBA port Y and you configure the AMBA port Y with the node address X, then the "extra byte" is not needed. I hope this answers your question.