本文整理汇总了C++中CYG_TEST_FAIL_FINISH函数的典型用法代码示例。如果您正苦于以下问题:C++ CYG_TEST_FAIL_FINISH函数的具体用法?C++ CYG_TEST_FAIL_FINISH怎么用?C++ CYG_TEST_FAIL_FINISH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CYG_TEST_FAIL_FINISH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: can0_thread
//===========================================================================
// READER THREAD
//===========================================================================
void can0_thread(cyg_addrword_t data)
{
cyg_uint32 len;
cyg_uint32 blocking;
cyg_can_event rx_event;
Cyg_ErrNo res;
blocking = 0;
len = sizeof(blocking);
if (ENOERR != cyg_io_set_config(hDrvFlexCAN, CYG_IO_SET_CONFIG_READ_BLOCKING ,&blocking, &len))
{
CYG_TEST_FAIL_FINISH("Error writing config of /dev/can0");
}
len = sizeof(rx_event);
res = cyg_io_read(hDrvFlexCAN, &rx_event, &len);
if (-EAGAIN == res)
{
CYG_TEST_PASS_FINISH("can_test1 test OK");
}
else if (-EINTR == res)
{
CYG_TEST_PASS_FINISH("can_test1 test OK");
}
else
{
CYG_TEST_FAIL_FINISH("Error reading from /dev/can0");
}
}
示例2: test_channel
static void
test_channel(const char *dev, cyg_io_handle_t channel)
{
Cyg_ErrNo res;
cyg_uint32 cfg_data;
cyg_uint32 len;
cyg_adc_sample_t sample;
int count;
diag_printf("\nTesting ADC channel '%s'\n", dev);
// Disable channel
res = cyg_io_set_config(channel, CYG_IO_SET_CONFIG_ADC_DISABLE, 0, 0);
if (res != ENOERR)
CYG_TEST_FAIL_FINISH("Failed to disable ADC channel");
// Make channel non-blocking
cfg_data = 0;
len = sizeof(cfg_data);
res = cyg_io_set_config(channel, CYG_IO_SET_CONFIG_READ_BLOCKING,
&cfg_data, &len);
if (res != ENOERR)
CYG_TEST_FAIL_FINISH("Failed to make ADC channel non-blocking");
// Set channel sampling rate
cfg_data = TEST_RATE;
len = sizeof(cfg_data);
res = cyg_io_set_config(channel, CYG_IO_SET_CONFIG_ADC_RATE,
&cfg_data, &len);
if (res != ENOERR)
CYG_TEST_FAIL_FINISH("Failed to set ADC channel sampling rate");
// Flush channel
do {
len = sizeof(sample);
res = cyg_io_read(channel, &sample, &len);
} while (res == ENOERR);
// Enable channel
res = cyg_io_set_config(channel, CYG_IO_SET_CONFIG_ADC_ENABLE, 0, 0);
if (res != ENOERR)
CYG_TEST_FAIL_FINISH("Failed to enable ADC channel");
// Read from channel
count = 0;
while (count < TEST_SAMPLES) {
len = sizeof(sample);
res = cyg_io_read(channel, &sample, &len);
if (res == ENOERR) {
diag_printf("%d\n", sample);
count++;
}
}
// Disable channel
res = cyg_io_set_config(channel, CYG_IO_SET_CONFIG_ADC_DISABLE, 0, 0);
if (res != ENOERR)
CYG_TEST_FAIL_FINISH("Failed to disable ADC channel");
}
示例3: cyg_start
externC void
cyg_start( void )
{
ezxml_t f1, team, driver;
const char * teamname;
int i;
CYG_TEST_INIT();
f1 = ezxml_parse_str(document, sizeof(document));
for (team = ezxml_child(f1, "team"); team; team = team->next) {
teamname = ezxml_attr(team, "name");
for (i=0,driver = ezxml_child(team, "driver");
driver;
driver = driver->next,i++) {
if (strcmp(results[i].driver, ezxml_child(driver, "name")->txt) ||
strcmp(results[i].team, teamname) ||
strcmp(results[i].points, ezxml_child(driver, "points")->txt))
CYG_TEST_FAIL("Parser failed first test");
}
}
if (strcmp(ezxml_get(f1, "team", 0, "driver", 1, "name", -1)->txt,
"David Coultard"))
CYG_TEST_FAIL_FINISH("Parser failed second test");
else
CYG_TEST_PASS_FINISH("Parser passed");
ezxml_free(f1);
}
示例4: main
int main(int argc, char **argv)
{
pthread_t thread;
pthread_attr_t attr;
void *retval;
CYG_TEST_INIT();
// Create test thread
pthread_attr_init( &attr );
pthread_attr_setstackaddr( &attr, (void *)&thread_stack[sizeof(thread_stack)] );
pthread_attr_setstacksize( &attr, sizeof(thread_stack) );
pthread_create( &thread,
&attr,
pthread_entry1,
(void *)0x12345678);
// Now join with it
pthread_join( thread, &retval );
// check retval
if( (long)retval == 0x12345679 )
CYG_TEST_PASS_FINISH( "pthread1" );
else
CYG_TEST_FAIL_FINISH( "pthread1" );
}
示例5: cyg_start
void
cyg_start(void)
{
CYG_TEST_INIT();
//
// open flexcan device driver
//
if (ENOERR != cyg_io_lookup("/dev/can0", &hDrvFlexCAN))
{
CYG_TEST_FAIL_FINISH("Error opening /dev/can0");
}
//
// create the two threads which access the CAN device driver
// a reader thread with a higher priority and a writer thread
// with a lower priority
//
cyg_thread_create(4, can0_thread,
(cyg_addrword_t) 0,
"can0_thread",
(void *) can0_thread_data.stack,
1024 * sizeof(long),
&can0_thread_data.hdl,
&can0_thread_data.obj);
cyg_thread_resume(can0_thread_data.hdl);
cyg_scheduler_start();
}
示例6: cyg_start
void
cyg_start(void)
{
CYG_TEST_INIT();
//
// open CAN device driver
//
if (ENOERR != cyg_io_lookup("/dev/can0", &hCAN0))
{
CYG_TEST_FAIL_FINISH("Error opening /dev/can0");
}
//
// create the thread that accesses the CAN device driver
//
cyg_thread_create(4, can0_thread,
(cyg_addrword_t) 0,
"can0_thread",
(void *) can0_thread_data.stack,
1024 * sizeof(long),
&can0_thread_data.hdl,
&can0_thread_data.obj);
cyg_thread_resume(can0_thread_data.hdl);
cyg_scheduler_start();
}
示例7: entry1
static void entry1( cyg_addrword_t data )
{
cyg_count32 val;
cyg_semaphore_peek(&s1, &val);
CHECK( 2 == val);
cyg_semaphore_wait(&s1);
cyg_semaphore_peek(&s1, &val);
CHECK( 1 == val);
cyg_semaphore_wait(&s1);
CHECK( 0 == q++ );
cyg_semaphore_peek(&s0, &val);
CHECK( 0 == val);
cyg_semaphore_post(&s0);
cyg_semaphore_wait(&s1);
CHECK( 2 == q++ );
cyg_semaphore_post(&s0);
cyg_semaphore_wait(&s1);
CHECK( 5 == q++ );
cyg_semaphore_peek(&s0, &val);
CHECK( 2 == val);
CHECK( cyg_semaphore_trywait(&s0) );
cyg_semaphore_peek(&s0, &val);
CHECK( 1 == val);
CHECK( cyg_semaphore_trywait(&s0) );
cyg_semaphore_peek(&s0, &val);
CHECK( 0 == val);
cyg_semaphore_post(&s2);
cyg_semaphore_wait(&s0);
CYG_TEST_FAIL_FINISH("Not reached");
}
示例8: server
void server(void)
{
int s_source;
struct sockaddr_in local,c_addr;
int c_len;
int len;
char *hello_string=" Hello eCos network \n";
diag_printf("UDP SERVER:");
diag_printf(hello_string);
s_source = socket(AF_INET, SOCK_DGRAM, 0);
if (s_source < 0) {
pexit("stream socket");
}
memset(&local, 0, sizeof(local));
local.sin_family = AF_INET;
local.sin_len = sizeof(local);
local.sin_port = ntohs(SOURCE_PORT);
local.sin_addr.s_addr = htonl(INADDR_ANY); //accepts everyone...
if(bind(s_source, (struct sockaddr *) &local, sizeof(local)) < 0) {
pexit("bind /source/ error");
}
c_len = sizeof(c_addr);
if ((len = recvfrom(s_source, data_buf, sizeof(data_buf),0,
(struct sockaddr *)&c_addr,&c_len)) < 0 ) {
CYG_TEST_FAIL_FINISH("I/O error");
}
diag_printf("SERVER : message arrived from %s\n",inet_ntoa(c_addr.sin_addr));
diag_printf("SERVER : Message : %s\n",data_buf);
close(s_source);
}
示例9: kmutex1_main
void kmutex1_main( void )
{
CYG_TEST_INIT();
cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "kmutex1-0",
(void *)stack[0], STACKSIZE, &thread[0], &thread_obj[0]);
cyg_thread_resume(thread[0]);
cyg_thread_create(4, entry1 , (cyg_addrword_t)1, "kmutex1-1",
(void *)stack[1], STACKSIZE, &thread[1], &thread_obj[1]);
cyg_thread_resume(thread[1]);
cyg_thread_create(4, entry2 , (cyg_addrword_t)2, "kmutex1-2",
(void *)stack[2], STACKSIZE, &thread[2], &thread_obj[2]);
cyg_thread_resume(thread[2]);
cyg_mutex_init( &m0 );
cyg_mutex_init( &m1 );
cyg_cond_init( &cvar0, &m0 );
cyg_cond_init( &cvar1, &m0 );
cyg_cond_init( &cvar2, &m1 );
cyg_scheduler_start();
CYG_TEST_FAIL_FINISH("Not reached");
}
示例10: client
void client(void)
{
int s_source;
struct sockaddr_in local;
int len;
diag_printf("client:started\n");
s_source = socket(AF_INET, SOCK_STREAM, 0);
if (s_source < 0) {
pexit("stream socket");
}
memset(&local, 0, sizeof(local));
local.sin_family = AF_INET;
local.sin_len = sizeof(local);
local.sin_port = htons(SOURCE_PORT);
local.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
if (connect(s_source, (struct sockaddr *)&local, sizeof(local)) < 0) {
pexit("Can't connect to target");
}
if ((len = write(s_source,data_buf_write,40)) < 0){
CYG_TEST_FAIL_FINISH( "Error writing buffer");
}
}
示例11: can_tx_thread
//===========================================================================
// Thread 1
//===========================================================================
void can_tx_thread(cyg_addrword_t data)
{
cyg_uint32 len;
cyg_can_message tx_msg;
cyg_uint32 msg_cnt = 0;
cyg_uint8 i;
CYG_CAN_MSG_SET_PARAM(tx_msg, 0, CYGNUM_CAN_ID_STD, 0, CYGNUM_CAN_FRAME_DATA);
//
// Prepare CAN message with a known CAN state
//
for (i = 0; i < 8; ++i)
{
tx_msg.data.bytes[i] = i;
}
while (msg_cnt < 0xF0)
{
tx_msg.id = msg_cnt;
len = sizeof(tx_msg);
if (ENOERR != cyg_io_write(hCAN_Tbl[0], &tx_msg, &len))
{
CYG_TEST_FAIL_FINISH("Error writing to channel 0");
}
tx_msg.id = msg_cnt;
len = sizeof(tx_msg);
if (ENOERR != cyg_io_write(hLoopCAN_Tbl[0], &tx_msg, &len))
{
CYG_TEST_FAIL_FINISH("Error writing to channel 1");
}
//
// Increment data in each single data byte
//
for (i = 0; i < 8; ++i)
{
tx_msg.data.bytes[i] += 1;
}
msg_cnt++;
tx_msg.dlc = (tx_msg.dlc + 1) % 9;
} // while (msg_cnt < 0x100)
}
示例12: finish
static void finish( cyg_ucount8 t )
{
cyg_mutex_lock( &m1 ); {
m1d |= 1<<t;
if( 0x7 == m1d )
CYG_TEST_PASS_FINISH("Kernel C API Mutex 1 OK");
cyg_cond_wait( &cvar2 );
} /* cyg_mutex_unlock( &m1 ); */
CYG_TEST_FAIL_FINISH("Not reached");
}
示例13: server
void server(void)
{
int s_source, e_source;
struct sockaddr_in e_source_addr, local;
int one = 1;
fd_set in_fds;
int len;
char *hello_string=" Hello eCos network \n";
diag_printf("TCP SERVER:");
diag_printf(hello_string);
s_source = socket(AF_INET, SOCK_STREAM, 0);
if (s_source < 0) {
pexit("stream socket");
}
if (setsockopt(s_source, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) {
pexit("setsockopt /source/ SO_REUSEADDR");
}
if (setsockopt(s_source, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one))) {
pexit("setsockopt /source/ SO_REUSEPORT");
}
memset(&local, 0, sizeof(local));
local.sin_family = AF_INET;
local.sin_len = sizeof(local);
local.sin_port = ntohs(SOURCE_PORT);
local.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
if(bind(s_source, (struct sockaddr *) &local, sizeof(local)) < 0) {
pexit("bind /source/ error");
}
listen(s_source, SOMAXCONN);
e_source = 0;
while (true) {
FD_ZERO(&in_fds);
FD_SET(s_source, &in_fds);
len = sizeof(e_source_addr);
if ((e_source = accept(s_source,(struct sockaddr *)&e_source_addr,&len))<0) {
pexit("accept /source/");
}
diag_printf("TCP SERVER connection from %s: %d\n",
inet_ntoa(e_source_addr.sin_addr),ntohs(e_source_addr.sin_port));
if (e_source != 0) {
break;
}
} /* while (true) */
if ((len = read(e_source, data_buf, MAX_BUF)) < 0 ) {
CYG_TEST_FAIL_FINISH( "I/O error" );
}
diag_printf("SERVER : %s\n",data_buf);
}
示例14: cyg_start
void
cyg_start(void)
{
cyg_uint32 len;
cyg_can_info_t can_cfg;
CYG_TEST_INIT();
//
// open flexcan device driver
//
if (ENOERR != cyg_io_lookup("/dev/can0", &hDrvFlexCAN))
{
CYG_TEST_FAIL_FINISH("Error opening /dev/can0");
}
//
// setup CAN baudrate 250 KBaud
//
can_cfg.baud = CYGNUM_CAN_KBAUD_250;
len = sizeof(can_cfg);
if (ENOERR != cyg_io_set_config(hDrvFlexCAN, CYG_IO_SET_CONFIG_CAN_INFO ,&can_cfg, &len))
{
CYG_TEST_FAIL_FINISH("Error writing config of /dev/can0");
}
//
// create the main thread
//
cyg_thread_create(4, can0_thread,
(cyg_addrword_t) 0,
"can0_thread",
(void *) can0_thread_data.stack,
1024 * sizeof(long),
&can0_thread_data.hdl,
&can0_thread_data.obj);
cyg_thread_resume(can0_thread_data.hdl);
cyg_scheduler_start();
}
示例15: zlib2_main
void zlib2_main( void )
{
CYG_TEST_INIT();
cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "zlib1",
(void *)stack[0], STACKSIZE,&thread[0], &thread_obj[0]);
cyg_thread_resume(thread[0]);
cyg_scheduler_start();
CYG_TEST_FAIL_FINISH("Not reached");
}