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.)
#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
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
bad_rtems_status(status, fail_level, text);
}
-#define CANGW_PRIORITY 30
#define SHELL_TASK_PRIORITY 50
#ifdef __cplusplus
#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
\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
-#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
}
-
-
-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 );
}
/* 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
#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
#SUBDIRS =
-include_HEADERS = system_def.h
+include_HEADERS = system_def.h networkconfig.h
--- /dev/null
+#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
+
/* 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)