From 95dab34de310d341c27cd986fec5f24522357b46 Mon Sep 17 00:00:00 2001 From: sangorrin Date: Thu, 5 Feb 2009 10:20:37 +0000 Subject: [PATCH] add test measuring using the parallel port with a logic analyzer git-svn-id: http://www.frescor.org/private/svn/frescor/fna/trunk@1539 35b4ef3e-fd22-0410-ab77-dab3279adceb --- .../test_frescan_fp_send_basic_pp_measures.c | 152 ++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 tests/tests_frescan/test_frescan_fp_send_basic_pp_measures.c diff --git a/tests/tests_frescan/test_frescan_fp_send_basic_pp_measures.c b/tests/tests_frescan/test_frescan_fp_send_basic_pp_measures.c new file mode 100644 index 0000000..3e608ce --- /dev/null +++ b/tests/tests_frescan/test_frescan_fp_send_basic_pp_measures.c @@ -0,0 +1,152 @@ +#include // perror +#include // exit +#include +#include "frescan.h" + +#define PUT_ERROR(s) {perror (s); exit (-1);} + +#define NETWORK 0 + +#define SENDER +// #define ENABLE_LOGGING +#define ENABLE_PARALLEL_PORT_TRACER + +#ifdef ENABLE_PARALLEL_PORT_TRACER +#include +#define PP_BASE_REG 0x378 +#define PP_DATA_REG 0 // Data port offset +#endif + +#if 0 +#include +#define DEBUG(x,args...) printf("%s: " x, __func__ , ##args) +#else +#define DEBUG(x,args...) +#endif + +#ifdef SENDER + +#define LOCAL_NODE 1 + +#ifdef ENABLE_LOGGING + +#include +#include +#include +#define LOG_DEVICE LOG_ETHERNET + +#endif + +int main () +{ + int i, ret; + frescan_send_params_t params; + char msg[200]; + int written; + frescan_init_params_t init_params; + struct timespec my_period, next_activation; + + init_params.net = NETWORK; + init_params.node = LOCAL_NODE; + init_params.tx_fp_max_prio = 10; + init_params.rx_num_of_channels = 5; + init_params.rx_channel_max_prio = NULL; + +#ifdef ENABLE_LOGGING + ret = logger_init(LOG_DEVICE); + assert(ret == 0); + + DEBUG("Changing to membuffer console\n"); + MEMBUFFER_CONSOLE_INIT(); +#endif + ret = frescan_init(&init_params); + if (ret != 0) PUT_ERROR ("could not init FRESCAN"); + + DEBUG("FRESCAN initialized (local node: %u)\n", LOCAL_NODE); + + params.net = NETWORK; + params.to = 0; + params.channel = 0; + params.flags = FRESCAN_FP | FRESCAN_ASYNC; + params.prio = 7; + + my_period.tv_sec = 0; + my_period.tv_nsec = 100000000; + + outb_p (PP_BASE_REG + PP_DATA_REG, 0x00); + + for(i=0; 1; i++) { + incr_timespec (next_activation, my_period); // the fosa one + clock_nanosleep(CLOCK_MONOTONIC, + TIMER_ABSTIME, + &next_activation, NULL); + + written = snprintf(msg, sizeof(msg), "his number is... %d", i); +#ifdef ENABLE_PARALLEL_PORT_TRACER + outb_p (PP_BASE_REG + PP_DATA_REG, 0xFF); +#endif + ret = frescan_send(¶ms, (uint8_t *)msg, 32); + if (ret != 0) PUT_ERROR ("could not send message\n"); + +#ifdef ENABLE_PARALLEL_PORT_TRACER + outb_p (PP_BASE_REG + PP_DATA_REG, 0x00); +#endif + DEBUG("SENT: %d\n", i); +#ifdef ENABLE_LOGGING + while (logger_manual_call() > 0); +#endif + } + + return 0; +} + +#else + +#define LOCAL_NODE 0 + +int main () +{ + int ret; + frescan_recv_params_t params; + uint8_t msg[3000]; + size_t recv_bytes; + frescan_node_t from; + frescan_init_params_t init_params; + frescan_prio_t prio; + struct timespec pulse_width = {0, 100000}; + + init_params.net = NETWORK; + init_params.node = LOCAL_NODE; + init_params.tx_fp_max_prio = 10; + init_params.rx_num_of_channels = 5; + init_params.rx_channel_max_prio = NULL; + + ret = frescan_init(&init_params); + if (ret != 0) PUT_ERROR ("could not init FRESCAN"); + + DEBUG("FRESCAN initialized (local node: %u)\n", LOCAL_NODE); + + params.net = NETWORK; + params.channel = 0; + params.flags = FRESCAN_SYNC; + + outb_p (PP_BASE_REG + PP_DATA_REG, 0x00); + + while (1) { + DEBUG("RECEIVING...\n"); + ret = frescan_recv(¶ms, (uint8_t *)msg, sizeof(msg), + &recv_bytes, &from, &prio); + if (ret != 0) PUT_ERROR ("could not send message"); +#ifdef ENABLE_PARALLEL_PORT_TRACER + outb_p (PP_BASE_REG + PP_DATA_REG, 0xFF); + nanosleep(&pulse_width, NULL); + outb_p (PP_BASE_REG + PP_DATA_REG, 0x00); +#endif + msg[recv_bytes] = '\0'; + DEBUG("RECEIVED: %s with prio:%u from:%u\n", msg, prio, from); + } + + return 0; +} + +#endif -- 2.39.2