Definition in file ethernet.h.
#include "supervisor.h"
#include "shell.h"
Go to the source code of this file.
Functions | |
eExecStatus | e_ethernet_cmd_get_config (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The set sensor config command: set the value of a config field of a sensor. Takes three parameters. The first parameter is the sensor's name, the second parameter is the config field name, the third parameter is the value. Format: set_sensor_config sensorname field=value. | |
eExecStatus | e_ethernet_cmd_set_config (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The get sensor config command: get the config fields value of a sensor. Takes one parameter, that is the sensor's name. Format: get_sensor_config sensorname. | |
eExecStatus | e_ip_stat (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The development only ip statck stats: display the TCP/IP stack stats on COM2. No parameters. Format: ipstat. | |
portTASK_FUNCTION (vStartEthernetTask, pvParameters) | |
configure lwIP and MACB, start lwIP layer, start servers tasks through lwIP services. | |
void | v_ethernet_stopResources (void) |
Stop the ethernet module resources. | |
void | vEthernetGetGWAddr (portCHAR *pcConfig) |
get the current GW address : formatted as follow : XXX.XXX.XXX.XXX | |
void | vEthernetGetIPAddr (portCHAR *pcConfig) |
get the current IP address : formatted as follow : XXX.XXX.XXX.XXX | |
void | vEthernetGetMACAddr (portCHAR *pcConfig) |
get the current MAC address : formatted as follow : XX:XX:XX:XX:XX:XX | |
void | vEthernetGetSubnetMask (portCHAR *pcConfig) |
get the current Subnet mask : formatted as follow : XXX.XXX.XXX.XXX | |
void | vStartEthernetTaskLauncher (unsigned portBASE_TYPE uxPriority) |
Create the vStartEthernetTask task. |
eExecStatus e_ethernet_cmd_get_config | ( | eModId | xModId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR * | av[], | |||
signed portCHAR ** | ppcStringReply | |||
) |
The set sensor config command: set the value of a config field of a sensor. Takes three parameters. The first parameter is the sensor's name, the second parameter is the config field name, the third parameter is the value. Format: set_sensor_config sensorname field=value.
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Input. The argument counter. For this command, should be 3. | |
av | Input. The argument vector. | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
Definition at line 343 of file ethernet.c.
References SHELL_ERRMSG_MEMALLOC, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, vEthernetGetGWAddr(), vEthernetGetIPAddr(), vEthernetGetMACAddr(), and vEthernetGetSubnetMask().
Referenced by e_syscmds_cmd_get_config().
00345 { 00346 portCHAR buf[18]; 00347 00348 if(ppcStringReply != NULL) 00349 { 00350 /* allocate a buffer for answer */ 00351 *ppcStringReply = (signed portCHAR *)pvPortMalloc(130); 00352 if( NULL == *ppcStringReply ) 00353 { 00354 *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_MEMALLOC; 00355 return( SHELL_EXECSTATUS_KO ); 00356 } 00357 /* add some static data */ 00358 strcpy((char *)*ppcStringReply, "macaddr="); 00359 /* get MAC addr and add it to the buffer */ 00360 vEthernetGetMACAddr(buf); 00361 strcat((char *)*ppcStringReply,buf); 00362 /* add some static data */ 00363 strcat((char *)*ppcStringReply,"\r\nipaddr="); 00364 /* get IP addr and add it to the buffer */ 00365 vEthernetGetIPAddr(buf); 00366 strcat((char *)*ppcStringReply,buf); 00367 /* add some static data */ 00368 strcat((char *)*ppcStringReply,"\r\nsubmask="); 00369 /* get Subnet Mask and add it to the buffer */ 00370 vEthernetGetSubnetMask(buf); 00371 strcat((char *)*ppcStringReply,buf); 00372 /* add some static data */ 00373 strcat((char *)*ppcStringReply,"\r\ngwaddr="); 00374 /* get GW addr and add it to the buffer */ 00375 vEthernetGetGWAddr(buf); 00376 strcat((char *)*ppcStringReply,buf); 00377 /* add some static data */ 00378 strcat((char *)*ppcStringReply,"\r\n"); 00379 /* no error, return */ 00380 return( SHELL_EXECSTATUS_OK ); 00381 } 00382 return( SHELL_EXECSTATUS_KO ); 00383 } 00384
eExecStatus e_ethernet_cmd_set_config | ( | eModId | xModId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR * | av[], | |||
signed portCHAR ** | ppcStringReply | |||
) |
The get sensor config command: get the config fields value of a sensor. Takes one parameter, that is the sensor's name. Format: get_sensor_config sensorname.
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Input. The argument counter. For this command, should be 1. | |
av | Input. The argument vector. | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
Definition at line 298 of file ethernet.c.
References config_file_set_value(), ETHERNET_CONFIG_FILE, SHELL_ERRMSG_CONFIGERROR, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and SHELL_MSG_REBOOT.
Referenced by e_syscmds_cmd_set_config().
00300 { 00301 00302 if (config_file_set_value(ETHERNET_CONFIG_FILE, ac, av) != 0) 00303 { 00304 if(ppcStringReply != NULL) 00305 { 00306 *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_CONFIGERROR; 00307 } 00308 return( SHELL_EXECSTATUS_KO ); 00309 } 00310 if(ppcStringReply != NULL) 00311 { 00312 /* allocate a buffer for answer */ 00313 *ppcStringReply = (signed portCHAR *)pvPortMalloc( strlen( SHELL_MSG_REBOOT ) +1 ); // Alloc 00314 if( NULL != *ppcStringReply ) 00315 { 00316 strcpy( (char *)*ppcStringReply, SHELL_MSG_REBOOT ); 00317 } 00318 } 00319 return( SHELL_EXECSTATUS_OK ); 00320 } 00321
eExecStatus e_ip_stat | ( | eModId | xModId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR * | av[], | |||
signed portCHAR ** | ppcStringReply | |||
) |
The development only ip statck stats: display the TCP/IP stack stats on COM2. No parameters. Format: ipstat.
xModId | Input. The module that is calling this function. | |
FsNavId | Ignored. | |
ac | Input. The argument counter. Ignored. | |
av | Input. The argument vector. Ignored | |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
Definition at line 528 of file ethernet.c.
References SHELL_EXECSTATUS_OK.
00530 { 00531 if( NULL != ppcStringReply ) 00532 *ppcStringReply = NULL; 00533 stats_display(); 00534 return( SHELL_EXECSTATUS_OK ); 00535 } 00536
portTASK_FUNCTION | ( | vStartEthernetTask | , | |
pvParameters | ||||
) |
configure lwIP and MACB, start lwIP layer, start servers tasks through lwIP services.
Definition at line 135 of file ethernet.c.
References CTRLPANEL_SMTP_CLIENT_PRIORITY, CTRLPANEL_SMTP_CLIENT_STACK_SIZE, CTRLPANEL_TFTP_SERVER_PRIORITY, CTRLPANEL_TFTP_SERVER_STACK_SIZE, CTRLPANEL_WEB_SERVER_PRIORITY, CTRLPANEL_WEB_SERVER_STACK_SIZE, and prvlwIPInit().
00136 { 00137 static const gpio_map_t MACB_GPIO_MAP = 00138 { 00139 {AVR32_MACB_MDC_0_PIN, AVR32_MACB_MDC_0_FUNCTION }, 00140 {AVR32_MACB_MDIO_0_PIN, AVR32_MACB_MDIO_0_FUNCTION }, 00141 {AVR32_MACB_RXD_0_PIN, AVR32_MACB_RXD_0_FUNCTION }, 00142 {AVR32_MACB_TXD_0_PIN, AVR32_MACB_TXD_0_FUNCTION }, 00143 {AVR32_MACB_RXD_1_PIN, AVR32_MACB_RXD_1_FUNCTION }, 00144 {AVR32_MACB_TXD_1_PIN, AVR32_MACB_TXD_1_FUNCTION }, 00145 {AVR32_MACB_TX_EN_0_PIN, AVR32_MACB_TX_EN_0_FUNCTION }, 00146 {AVR32_MACB_RX_ER_0_PIN, AVR32_MACB_RX_ER_0_FUNCTION }, 00147 {AVR32_MACB_RX_DV_0_PIN, AVR32_MACB_RX_DV_0_FUNCTION }, 00148 {AVR32_MACB_TX_CLK_0_PIN, AVR32_MACB_TX_CLK_0_FUNCTION} 00149 }; 00150 00151 // Assign GPIO to MACB 00152 gpio_enable_module(MACB_GPIO_MAP, sizeof(MACB_GPIO_MAP) / sizeof(MACB_GPIO_MAP[0])); 00153 00154 00155 /* Setup lwIP. */ 00156 prvlwIPInit(); 00157 00158 #if (HTTP_USED == 1) 00159 /* Create the WEB server task. This uses the lwIP RTOS abstraction layer.*/ 00160 sys_thread_new( "WEB", vBasicWEBServer, ( void * ) NULL, 00161 CTRLPANEL_WEB_SERVER_STACK_SIZE, 00162 CTRLPANEL_WEB_SERVER_PRIORITY ); 00163 #endif 00164 00165 #if (TFTP_USED == 1) 00166 /* Create the TFTP server task. This uses the lwIP RTOS abstraction layer.*/ 00167 sys_thread_new( "TFTP", vBasicTFTPServer, ( void * ) NULL, 00168 CTRLPANEL_TFTP_SERVER_STACK_SIZE, 00169 CTRLPANEL_TFTP_SERVER_PRIORITY ); 00170 #endif 00171 00172 #if (SMTP_USED == 1) 00173 /* Create the SMTP Client task. This uses the lwIP RTOS abstraction layer.*/ 00174 sys_thread_new( "SMTP", vBasicSMTPClient, ( void * ) NULL, 00175 CTRLPANEL_SMTP_CLIENT_STACK_SIZE, 00176 CTRLPANEL_SMTP_CLIENT_PRIORITY ); 00177 #endif 00178 // Kill this task. 00179 vTaskDelete(NULL); 00180 }
void v_ethernet_stopResources | ( | void | ) |
Stop the ethernet module resources.
Definition at line 194 of file ethernet.c.
Referenced by e_syscmds_reboot().
void vEthernetGetGWAddr | ( | portCHAR * | pcConfig | ) |
get the current GW address : formatted as follow : XXX.XXX.XXX.XXX
pcConfig | Input/Output. The response string. If Input is NULL, no response string will be output. The caller has to allocate this buffer |
Definition at line 269 of file ethernet.c.
References MACB_if, and sprintf().
Referenced by e_ethernet_cmd_get_config().
00269 { 00270 if (pcConfig != NULL) 00271 { 00272 sprintf(pcConfig,"%d.%d.%d.%d", (u16_t)(ntohl((MACB_if.gw.addr) >> 24) & 0xff), 00273 (u16_t)(ntohl((MACB_if.gw.addr) >> 16) & 0xff), 00274 (u16_t)(ntohl((MACB_if.gw.addr) >> 8) & 0xff), 00275 (u16_t) ntohl((MACB_if.gw.addr) & 0xff )); 00276 } 00277 } 00278
void vEthernetGetIPAddr | ( | portCHAR * | pcConfig | ) |
get the current IP address : formatted as follow : XXX.XXX.XXX.XXX
pcConfig | Input/Output. The response string. If Input is NULL, no response string will be output. The caller has to allocate this buffer |
Definition at line 228 of file ethernet.c.
References MACB_if, and sprintf().
Referenced by e_ethernet_cmd_get_config(), prulweb_BuildErrorTail(), and prvEthernetConfigureInterface().
00229 { 00230 if (pcConfig != NULL) 00231 { 00232 sprintf(pcConfig,"%d.%d.%d.%d", (u16_t)(ntohl((MACB_if.ip_addr.addr) >> 24) & 0xff), 00233 (u16_t)(ntohl((MACB_if.ip_addr.addr) >> 16) & 0xff), 00234 (u16_t)(ntohl((MACB_if.ip_addr.addr) >> 8) & 0xff), 00235 (u16_t) ntohl((MACB_if.ip_addr.addr) & 0xff )); 00236 } 00237 }
void vEthernetGetMACAddr | ( | portCHAR * | pcConfig | ) |
get the current MAC address : formatted as follow : XX:XX:XX:XX:XX:XX
pcConfig | Input/Output. The response string. If Input is NULL, no response string will be output. The caller has to allocate this buffer |
Definition at line 209 of file ethernet.c.
References MACB_if, and sprintf().
Referenced by e_ethernet_cmd_get_config().
00210 { 00211 if (pcConfig != NULL) 00212 { 00213 sprintf(pcConfig, "%02x:%02x:%02x:%02x:%02x:%02x", MACB_if.hwaddr[0], MACB_if.hwaddr[1], 00214 MACB_if.hwaddr[2], MACB_if.hwaddr[3], 00215 MACB_if.hwaddr[4], MACB_if.hwaddr[5]); 00216 } 00217 }
void vEthernetGetSubnetMask | ( | portCHAR * | pcConfig | ) |
get the current Subnet mask : formatted as follow : XXX.XXX.XXX.XXX
pcConfig | Input/Output. The response string. If Input is NULL, no response string will be output. The caller has to allocate this buffer |
Definition at line 249 of file ethernet.c.
References MACB_if, and sprintf().
Referenced by e_ethernet_cmd_get_config().
00249 { 00250 if (pcConfig != NULL) 00251 { 00252 sprintf(pcConfig,"%d.%d.%d.%d", (u16_t)(ntohl((MACB_if.netmask.addr) >> 24) & 0xff), 00253 (u16_t)(ntohl((MACB_if.netmask.addr) >> 16) & 0xff), 00254 (u16_t)(ntohl((MACB_if.netmask.addr) >> 8) & 0xff), 00255 (u16_t) ntohl((MACB_if.netmask.addr) & 0xff )); 00256 } 00257 } 00258
void vStartEthernetTaskLauncher | ( | unsigned portBASE_TYPE | uxPriority | ) |
Create the vStartEthernetTask task.
Definition at line 125 of file ethernet.c.
References configMINIMAL_STACK_SIZE.
Referenced by portTASK_FUNCTION().
00126 { 00127 /* Spawn the Sentinel task. */ 00128 xTaskCreate( vStartEthernetTask, ( const signed portCHAR * )"ETHLAUNCH", 00129 configMINIMAL_STACK_SIZE + 192, NULL, uxPriority, ( xTaskHandle * )NULL ); 00130 }