]> rtime.felk.cvut.cz Git - can-benchmark.git/commitdiff
Commit adding basic ethernet capability to the GW application - responding to pings.
authorMartin Hořeňovský <Martin.Horenovsky@gmail.com>
Wed, 21 Aug 2013 14:32:42 +0000 (16:32 +0200)
committerMartin Hořeňovský <Martin.Horenovsky@gmail.com>
Wed, 21 Aug 2013 14:32:42 +0000 (16:32 +0200)
Ethernet driver needs to be activated first with "startNET", this will probably be changed in the future to autoactiva
tion (pending discussion about whether the (extremely minor) overhead matters in the benchmarking of CAN GW.)

rtems/gw/cangw/Makefile.omk
rtems/gw/cangw/app_def.h
rtems/gw/cangw/helpers.c
rtems/gw/cangw/helpers.h
rtems/gw/cangw/init.c
rtems/gw/cangw/system.h
rtems/gw/system_opt/Makefile.omk
rtems/gw/system_opt/networkconfig.h [new file with mode: 0644]
rtems/gw/system_opt/system_def.h

index 63169587e845fdd407279b7349ae2e89486b8b37..abea9ebfd346a07cd9118e11601eaaef1895f04d 100644 (file)
@@ -6,5 +6,10 @@ bin_PROGRAMS = cangw
 #lib_LIBRARIES = 
 
 #include_HEADERS = 
+\r
+#I am not entirely sure these two are needed, but according to documentation, they are.\r
+CFLAGS_LD += HeapSize=0x80000\r
+MANAGERS = io event semaphore\r
 
 cangw_SOURCES += init.c gw.c helpers.c
+\r
index c2f13eb23cfffeb86b79f47396850df2d226484b..79a8a285d04248528966cf76b28531e85c3f9e80 100644 (file)
 extern "C" {
 #endif
 
-COND_EXTERN rtems_id   CAN_A_to_B_id;           /* task listening on A, sends through B */\r
-COND_EXTERN rtems_id   CAN_B_to_A_id;           /* task listening on B, sends through A */\r
-COND_EXTERN rtems_name CAN_A_to_B_name;         /* First task's name */
-COND_EXTERN rtems_name CAN_B_to_A_name;         /* Seconds task's name */\r
-
-rtems_task CAN_GW_1(rtems_task_argument arg);\r
-rtems_task CAN_GW_2(rtems_task_argument arg);
-
 void bad_rtems_status(rtems_status_code status, int fail_level, const char *text);
 
 static inline
@@ -30,7 +22,6 @@ void check_rtems_status(rtems_status_code status, int fail_level, const char *te
      bad_rtems_status(status, fail_level, text);
 }
 
-#define CANGW_PRIORITY     30
 #define SHELL_TASK_PRIORITY 50
 
 #ifdef __cplusplus
index 0f9424224a7a0e9c116970fcbe85915bfa62d817..117c46938c57812f71593b6e682900eadbe7c613 100644 (file)
@@ -17,6 +17,9 @@
 #include "helpers.h"\r
 #include "gw.h"\r
 \r
+#include <rtems/rtems_bsdnet.h>\r
+#include "networkconfig.h" \r
+\r
 \r
 extern unsigned long int total_1, total_2, succ_1, succ_2, err_1, err_2;\r
 \r
@@ -87,4 +90,29 @@ int start_can(int argc, char** argv){
 \r
 int end_can(int argc, char** argv){\r
     return end_GW();\r
+}\r
+\r
+int show_net(int argc, char** argv){\r
+    rtems_bsdnet_show_if_stats();\r
+    rtems_bsdnet_show_ip_stats();\r
+    rtems_bsdnet_show_icmp_stats();\r
+    rtems_bsdnet_show_tcp_stats();\r
+    rtems_bsdnet_show_udp_stats();\r
+    rtems_bsdnet_show_mbuf_stats();\r
+    rtems_bsdnet_show_inet_routes();\r
+    return 0;\r
+}\r
+\r
+int start_net(int argc, char** argv){\r
+    int res;\r
+    printf("Initializing Network\n");\r
+    res = rtems_bsdnet_initialize_network ();\r
+    if (res < 0){\r
+        printf("Error while initializing network: %d    %s\n", errno, strerror(errno));\r
+        return 1;\r
+    }\r
+    printf("Success\n");\r
+    printf("About to show routes.\n");\r
+    rtems_bsdnet_show_inet_routes (); \r
+    return 0;\r
 }
\ No newline at end of file
index 0c3a0d012f8a463fa1b1509743bf52f151dbbfba..efda330855d1d57fd4ebef6fbf9cee85de68d733 100644 (file)
@@ -1,20 +1,11 @@
-#include <system_def.h>\r
-#include "system.h"\r
-#include "app_def.h"\r
-#include <unistd.h>\r
-#include <fcntl.h>\r
-#include <stdio.h>\r
-#include <errno.h>\r
-#include <stdlib.h>\r
-#include <rtems/error.h>\r
-#include <rtems/monitor.h>\r
-#include <rtems/shell.h>\r
-\r
-#include <bsp/mscan.h>\r
-#include <bsp/mscan-base.h>\r
-\r
+#ifndef __HELPERS_H_\r
+#define __HELPERS_H_\r
 \r
 int start_can(int argc, char** argv);\r
 int end_can(int argc, char** argv);\r
 int print_regs(int argc, char** argv);\r
-int print_can_totals(int argc, char** argv);
\ No newline at end of file
+int print_can_totals(int argc, char** argv);\r
+int start_net(int argc, char** argv);\r
+int show_net(int argc, char** argv);\r
+\r
+#endif
\ No newline at end of file
index c7209d17365a80b474235fdff07052e7407ece3f..63e00eab0c70060633dcba2fe653cb7bbe6100b6 100644 (file)
@@ -58,50 +58,51 @@ void bad_rtems_status(rtems_status_code status, int fail_level, const char *text
 }
 
 
-
-
-rtems_task Init(
-  rtems_task_argument ignored
-)
-{
-  rtems_status_code status;
-
-  printf( "\n\nRTEMS v "
-          BUILD_VERSION_STRING(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
-         "\n");
-  
-  rtems_monitor_init(RTEMS_MONITOR_SUSPEND|RTEMS_MONITOR_GLOBAL);
-  /*rtems_capture_cli_init (0);*/
-  
-  printf( "Starting application " SW_VER_ID " v "
-          BUILD_VERSION_STRING(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH)
-         "\n" );
 \r
-  
-
-  rtems_shell_init("SHLL",RTEMS_MINIMUM_STACK_SIZE+0x1000,
-              SHELL_TASK_PRIORITY,"/dev/console",1,0, NULL);
 
-  rtems_shell_add_cmd("startGW", "app",
-                "initialize can driver and startGW",
-                start_can);
-  
-  rtems_shell_add_cmd("stopGW", "app",
-                "stops GW",
-                end_can);
-           
-  rtems_shell_add_cmd("printvar", "app",
-                "prints info from vars",
-                print_regs);\r
-                \r
-  rtems_shell_add_cmd("printcan", "app",\r
-                "prints error rate from CANs",\r
-                print_can_totals);
-\r
-                \r
-                //rtems_monitor_wakeup();
-
-  status = rtems_task_delete( RTEMS_SELF );
-  
-  exit( 0 );
+rtems_task Init(rtems_task_argument ignored){
+    rtems_status_code status;
+    
+    printf( "\n\nRTEMS v "
+            BUILD_VERSION_STRING(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
+        "\n");
+    
+    rtems_monitor_init(RTEMS_MONITOR_SUSPEND|RTEMS_MONITOR_GLOBAL);
+    /*rtems_capture_cli_init (0);*/
+    
+    printf( "Starting application " SW_VER_ID " v "
+            BUILD_VERSION_STRING(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH)
+        "\n" );
+    \r
+    
+    rtems_shell_init("SHLL", RTEMS_MINIMUM_STACK_SIZE+0x1000,
+                SHELL_TASK_PRIORITY, "/dev/console", 1, 0, NULL);
+    
+    rtems_shell_add_cmd("startGW", "app",
+                    "initialize can driver and startGW",
+                    start_can);
+    
+    rtems_shell_add_cmd("stopGW", "app",
+                    "stops GW",
+                    end_can);
+            
+    rtems_shell_add_cmd("printvar", "app",
+                    "prints info from vars",
+                    print_regs);\r
+                    \r
+    rtems_shell_add_cmd("printcan", "app",\r
+                    "prints error rate from CANs",\r
+                    print_can_totals);
+    \r
+    rtems_shell_add_cmd("startNET", "app",\r
+                    "tries to start network adapter",\r
+                    start_net);\r
+    \r
+    rtems_shell_add_cmd("showNET", "app",\r
+                    "prints some diagnostic info from network adapter/driver",\r
+                    show_net);\r
+    
+    status = rtems_task_delete( RTEMS_SELF );
+    
+    exit( 0 );
 }
index 727955121fbe7e1f8f16c86dec744a09dd35b071..0673310faf78444a05ae1f8c392191ec3326ce1a 100644 (file)
@@ -23,7 +23,7 @@ rtems_task Init(
 
 /* configuration information */
 
-#include <bsp.h> /* for device driver prototypes */
+#include <bsp.h> /* for device driver prototypes */\r
 
 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
@@ -39,6 +39,7 @@ rtems_task Init(
 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS        2
 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
 #define CONFIGURE_MAXIMUM_DRIVERS (CONFIGURE_NUMBER_OF_DRIVERS+10)
+\r
 
 #ifdef RTEMS_POSIX_API
 #define CONFIGURE_MAXIMUM_POSIX_THREADS          32
index ab511aebb35638fd08c2b7e8a6a30abc4fee2ca1..532eb88244895cc6598acb6735dba41610bd1d14 100644 (file)
@@ -1,3 +1,3 @@
 #SUBDIRS = 
 
-include_HEADERS = system_def.h
+include_HEADERS = system_def.h networkconfig.h
diff --git a/rtems/gw/system_opt/networkconfig.h b/rtems/gw/system_opt/networkconfig.h
new file mode 100644 (file)
index 0000000..a162114
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef __NETWORKCONFIG_H__
+#define __NETWORKCONFIG_H__
+
+#include <rtems/rtems_bsdnet.h>
+#include <bsp.h>
+
+/* This was taken from existing example, driver failed to provide its own, so why not. */\r
+static char ethernet_address[6] = {0x00, 0x04, 0x9F, 0x00, 0x27, 0x50 };\r
+\r
+extern void rtems_bsdnet_loopattach();\r
+\r
+/* config for loopback device */\r
+static struct rtems_bsdnet_ifconfig loopback_config = {\r
+       "lo0",\r
+       rtems_bsdnet_loopattach,\r
+       NULL,\r
+       "127.0.0.1",\r
+       "255.0.0.0"\r
+    /* Rest of the struct is set to 0 (is defaulted) */\r
+};\r
+\r
+/* config for ethernet */\r
+static struct rtems_bsdnet_ifconfig netdriver_config = {\r
+       RTEMS_BSP_NETWORK_DRIVER_NAME,\r
+       RTEMS_BSP_NETWORK_DRIVER_ATTACH,\r
+       &loopback_config, /* link to next interface */\r
+       "192.168.2.3", /* IP address */\r
+       "255.255.255.0", /* IP address net mask */\r
+       ethernet_address /* ethernet hardware address, 0 - supplied by driver according to documentation, but it caused error when tested */\r
+    \r
+       /* rest of the struct is set to 0 (is defaulted) */\r
+};\r
+\r
+/* Main config. */
+struct rtems_bsdnet_config rtems_bsdnet_config = {
+       &netdriver_config, /* This entry points to the head of the ifconfig chain. */
+       NULL, /* rtems_bsdnet_do_bootp if it should use bootp, null otherwise */
+       /* From here on, zero means default value. */\r
+    100, /* network task priority (default 100) */
+       65792, /* mbuf bytecount (default 64kbytes) */\r
+    /* Using default sizes stops RTEMS from answering to pings. (Probably because it allocates too few buffer for an answer.). */
+       263168, //180584, /* mbuf cluster bytecount (default 128kbytes) */
+       "midam_deska", /* hostname (default BOOTP) */
+       "testdomain", /* domain name (default BOOTP) */
+       "192.168.2.2", /* gateway (default BOOTP) */
+       "192.168.2.2", /* log_host (default BOOTP) */
+       { "192.168.2.2", }, /* name_server[3] (default BOOTP) */
+       { "192.168.2.2", }, /* ntp_server[3] (default BOOTP) */
+       0, /* sb efficiency (default 2) */
+       0, /* udp tx buf size (default 9216 bytes) */
+       0, /* udp rx buf size (default 40 * (1024 + sizeof(struct sockaddr_in) bytes) */
+       0, /* tcp tx buf size (default 16 * 1024 bytes) */
+       0  /* tcp rx buf size (default 16 * 1024 bytes) */
+};
+
+#endif
+
index 0ae03aab1ddb8c55b5ad9e7742c8e0fdccb73dc2..49c60ed9bfd865aa9bf2bc90b3454d4544f60599 100644 (file)
@@ -7,19 +7,19 @@
 /* Software version */
 #define SW_VER_ID      "CANGW"
 #define SW_VER_MAJOR   0
-#define SW_VER_MINOR   1
+#define SW_VER_MINOR   3
 #define SW_VER_PATCH   0
 #define SW_VER_CODE    VER_CODE(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH)
 /* Hardware version */
 #define HW_VER_ID      "RYU"
-#define HW_VER_MAJOR   1
+#define HW_VER_MAJOR   0
 #define HW_VER_MINOR   0
-#define HW_VER_PATCH   2
+#define HW_VER_PATCH   0
 #define HW_VER_CODE    VER_CODE(HW_VER_MAJOR,HW_VER_MINOR,HW_VER_PATCH)
 /* Version of mechanical  */
 #define MECH_VER_ID     "???"
 #define MECH_VER_MAJOR  0
-#define MECH_VER_MINOR  1
+#define MECH_VER_MINOR  0
 #define MECH_VER_PATCH  0
 #define MECH_VER_CODE  VER_CODE(MECH_VER_MAJOR,MECH_VER_MINOR,MECH_VER_PATCH)