Code: Select all
/** \brief Receive the next connect event.
*
* \note This can be used in a select statement.
*
* Upon receiving the event, the xtcp_connection_t structure conn
* is instantiated with information of the event and the connection
* it is on.
*
* \param c_xtcp chanend connected to the wifi server
* \param conn the connection relating to the current event
*/
transaction xtcp_event(chanend c_xtcp, xtcp_connection_t &conn);
Code: Select all
// This can be used in a select statement.
#pragma unsafe arrays
transaction xtcp_event(chanend c_xtcp, xtcp_connection_t &conn)
{
for(int i = 0; i < sizeof(conn) >> 2; i++)
{
c_xtcp :> (conn,unsigned int[])[i];
}
}
Code: Select all
while(1)
{
select
{
case xtcp_event(c_wifi, conn):
{
wifi_led_cmd = httpd_handle_event(c_wifi, conn); // Teig
event_cnt++;
i_wifi_led_server.command (wifi_led_cmd);
break;
} // case xtcp_event(c_wifi, conn):
} // select
} // while(1)
(As mentioned the code I use (app_tiwisl_simple_webserver ) does not use lib_xtcp (for XTCP) but module_wifi_tiwisl (for wifi_tiwisl_server) that takes care of the Wi-Fi TiWi-SL)To use the webserver you must have an instance of an XTCP server running on your system. You can then write a function that implements a task that handles tcp events. This may do other functions/handle other tcp traffic as well as implementing the webserver. Here is a rough template of how the code should look:
Below is some pseudocode, perhaps to see c_wifi /c_xtcp in scope:
Code: Select all
while(1)
{
select
{
case xtcp_event(c_wifi,conn):
{ // "transcation":
for(int i = 0; i < sizeof(conn) >> 2; i++)
{
c_wifi :> (conn,unsigned int[])[i];
}
{
wifi_led_cmd = httpd_handle_event(c_wifi, conn); // Teig
event_cnt++;
i_wifi_led_server.command (wifi_led_cmd);
break;
} // case xtcp_event(c_wifi, conn):
} // select
} // while(1)
My problem is, even after having read the XC specs and books I am not certain if I understand this. I'll try to explain what I think I understand.
I observe that there is one event arriving on c_wifi and it's also used to send data back again. On the client side.
xtcp_event certainly is a synchronization point. c_wifi is used by the sender in module_wifi_tiwisl to fill up the conn struct/array asynchronously across a core and then the synchronization is handled by the enclosing transaction statement? I guess this syntax does this array filling: c_wifi :> (conn,unsigned int[]); And this is unsafe by the compiler rules, but not as it is coded?)
I assume that defining xtcp_event in another module than the user/client/has-select is a way to make general task-based library modules clean?
I have started a task diagram (attached). I do this because I plan to port the WiFi101 SW for the ATWINC1500 module into XC code [1]. To do that I need to understand the XMOS solution with the WiFi sliceCARD (that I obsolete). Much about this in my blog notes.
[1] http://www.teigfam.net/oyvind/home/tech ... rary-port/ (Disclaimer: no money, no gifts, no ads, just a private hobby)