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().
00346 { 00347 portCHAR buf[18]; 00348 00349 if(ppcStringReply != NULL) 00350 { 00351 /* allocate a buffer for answer */ 00352 *ppcStringReply = (signed portCHAR *)pvPortMalloc(130); 00353 if( NULL == *ppcStringReply ) 00354 { 00355 *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_MEMALLOC; 00356 return( SHELL_EXECSTATUS_KO ); 00357 } 00358 /* add some static data */ 00359 strcpy((char *)*ppcStringReply, "macaddr="); 00360 /* get MAC addr and add it to the buffer */ 00361 vEthernetGetMACAddr(buf); 00362 strcat((char *)*ppcStringReply,buf); 00363 /* add some static data */ 00364 strcat((char *)*ppcStringReply,"\r\nipaddr="); 00365 /* get IP addr and add it to the buffer */ 00366 vEthernetGetIPAddr(buf); 00367 strcat((char *)*ppcStringReply,buf); 00368 /* add some static data */ 00369 strcat((char *)*ppcStringReply,"\r\nsubmask="); 00370 /* get Subnet Mask and add it to the buffer */ 00371 vEthernetGetSubnetMask(buf); 00372 strcat((char *)*ppcStringReply,buf); 00373 /* add some static data */ 00374 strcat((char *)*ppcStringReply,"\r\ngwaddr="); 00375 /* get GW addr and add it to the buffer */ 00376 vEthernetGetGWAddr(buf); 00377 strcat((char *)*ppcStringReply,buf); 00378 /* add some static data */ 00379 strcat((char *)*ppcStringReply,"\r\n"); 00380 /* no error, return */ 00381 return( SHELL_EXECSTATUS_OK ); 00382 } 00383 return( SHELL_EXECSTATUS_KO ); 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().
00301 { 00302 00303 if (config_file_set_value(ETHERNET_CONFIG_FILE, ac, av) != 0) 00304 { 00305 if(ppcStringReply != NULL) 00306 { 00307 *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_CONFIGERROR; 00308 } 00309 return( SHELL_EXECSTATUS_KO ); 00310 } 00311 if(ppcStringReply != NULL) 00312 { 00313 /* allocate a buffer for answer */ 00314 *ppcStringReply = (signed portCHAR *)pvPortMalloc( strlen( SHELL_MSG_REBOOT ) +1 ); // Alloc 00315 if( NULL != *ppcStringReply ) 00316 { 00317 strcpy( (char *)*ppcStringReply, SHELL_MSG_REBOOT ); 00318 } 00319 } 00320 return( SHELL_EXECSTATUS_OK ); 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 526 of file ethernet.c.
References SHELL_EXECSTATUS_OK.
00529 { 00530 if( NULL != ppcStringReply ) 00531 *ppcStringReply = NULL; 00532 stats_display(); 00533 return( SHELL_EXECSTATUS_OK ); 00534 }
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 195 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().
00270 { 00271 if (pcConfig != NULL) 00272 { 00273 sprintf(pcConfig,"%d.%d.%d.%d", (u16_t)(ntohl((MACB_if.gw.addr) >> 24) & 0xff), 00274 (u16_t)(ntohl((MACB_if.gw.addr) >> 16) & 0xff), 00275 (u16_t)(ntohl((MACB_if.gw.addr) >> 8) & 0xff), 00276 (u16_t) ntohl((MACB_if.gw.addr) & 0xff )); 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 229 of file ethernet.c.
References MACB_if, and sprintf().
Referenced by e_ethernet_cmd_get_config(), prulweb_BuildErrorTail(), and prvEthernetConfigureInterface().
00230 { 00231 if (pcConfig != NULL) 00232 { 00233 sprintf(pcConfig,"%d.%d.%d.%d", (u16_t)(ntohl((MACB_if.ip_addr.addr) >> 24) & 0xff), 00234 (u16_t)(ntohl((MACB_if.ip_addr.addr) >> 16) & 0xff), 00235 (u16_t)(ntohl((MACB_if.ip_addr.addr) >> 8) & 0xff), 00236 (u16_t) ntohl((MACB_if.ip_addr.addr) & 0xff )); 00237 } 00238 }
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 210 of file ethernet.c.
References MACB_if, and sprintf().
Referenced by e_ethernet_cmd_get_config().
00211 { 00212 if (pcConfig != NULL) 00213 { 00214 sprintf(pcConfig, "%02x:%02x:%02x:%02x:%02x:%02x", MACB_if.hwaddr[0], MACB_if.hwaddr[1], 00215 MACB_if.hwaddr[2], MACB_if.hwaddr[3], 00216 MACB_if.hwaddr[4], MACB_if.hwaddr[5]); 00217 } 00218 }
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().
00250 { 00251 if (pcConfig != NULL) 00252 { 00253 sprintf(pcConfig,"%d.%d.%d.%d", (u16_t)(ntohl((MACB_if.netmask.addr) >> 24) & 0xff), 00254 (u16_t)(ntohl((MACB_if.netmask.addr) >> 16) & 0xff), 00255 (u16_t)(ntohl((MACB_if.netmask.addr) >> 8) & 0xff), 00256 (u16_t) ntohl((MACB_if.netmask.addr) & 0xff )); 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 }