int main(void) // Input : - // Output : - // Function : main function. Runs the init function and then loops { //Initialization disable_global_int(); SysTick_init(); GPIO_init(); swtimers_init(); RTCS_init(); UART0_init(19200, 8, 1, 0); enable_global_int(); LCD_init(); queue_init(&display_lcd_queue); queue_init(&uart0_rx_queue); numpad_init(); open_queue(Q_LCD); open_queue(Q_INPUT); start_task( TASK_RTC, RTC_task); start_task( TASK_DISPLAY, display_task); start_task( TASK_LCD, LCD_task); start_task( TASK_NUMPAD, numpad_task); start_task( TASK_UI, ui_task); start_task( TASK_UART0, UART0_task); schedule(); return (0); }
int main(int argc, char** argv) { int msqid = open_queue(); if (msqid == -1) { printf("error when opened the queue!\n"); return -1; } while (1) { int ret = msgrcv(msqid, rcvbuf, MSGS_LEN, MSG_TYPE, IPC_NOWAIT); //do_statistic(); if (ENOMSG == errno || EAGAIN == errno){ usleep(12000); continue; } if (ret == -1){ printf("msgrcv failed!\n"); } else{ do_statistic(); printf("msgrcv success!!!\n"); } usleep(12030*10); } return 0; }
int main(){ int qid; key_t msgkey; /* struct mymsgbuf{ long mtype; int request; double salary; }msg; */ struct mymsgbuf msg; msgkey = ftok(".",'m'); if(( qid = open_queue(msgkey)) == -1){ perror("open_queue"); exit(-1); } msg.mtype = 1; msg.request = 1; msg.salary = 1000.00; if((send_message( qid,&msg)) == -1){ perror("send_message"); exit(-1); } }
// TODO make private void eventc_component_init(comp_t * comp_details) { /* Set instance id */ comp_details->instance_id = next_instance_id++; /* Open queue */ comp_details->queue_id = open_queue(comp_details->instance_id); /* Start thread */ start_thread(comp_details); printf("%s: Instance created. Comp %s, Instance %d\n", __FUNCTION__, comp_details->comp_name, comp_details->instance_id); }
void mud_recv_message( void ) { struct mud_msgbuf qbuf; int ret; if( open_queue( ) < 0 ) return; while( ( ret = msgrcv( qid, &qbuf, MAX_MSGBUF_LENGTH, mud_port, IPC_NOWAIT ) ) > 0 ) { string txt = qbuf.mtext; recv_text_handler( txt ); } if( ret == -1 && errno != ENOMSG ) bug( "%s: errno: %d", __func__, errno ); }
main() { struct decrimsg msg; /* message */ int msgid; /* identificateur de la file */ char *message_t10 = "Ici l'EFREI: bonjour tout le monde" ; /* texte du message */ /* * Récupération de l'identificateur de la file de messages */ msgid = open_queue( CLE_MESS ); if (msgid == -1){ printf ("Erreur à la creation de la file de message"); return (EXIT_FAILURE); } /* * Envoi d'un message (commencer par remplir les champs de msg) */ strcpy(msg.mtext,message_t10) ; /* Champ mtext rempli */ msg.pid = getpid(); msg.mtype = MON_TYP_CLI; /* valeur arbitraire */ printf("client: envoi du message:%s\n",msg.mtext) ; if ( send_message(msgid, &msg) == -1 ){ printf("Erreur a l'envoi du message dans la file"); return (EXIT_FAILURE); } /* * Réception d'un message */ printf("client: attente de message\n") ; if ( read_message(msgid, MON_TYP_SER, &msg ) == -1 ){ printf("Erreur a l'envoi du message dans la file"); return (EXIT_FAILURE); } printf("processus client = %d reçoit un message du serveur %d\ntexte: %s\n", getpid(), msg.pid, msg.mtext); return (EXIT_SUCCESS); }
void mud_send_message( const char *arg ) { struct mud_msgbuf qbuf; int x; if( open_queue( ) < 0 ) return; snprintf( qbuf.mtext, MAX_MSGBUF_LENGTH, "%s", arg ); for( x = 0; other_ports[x] != -1; ++x ) { if( other_ports[x] == mud_port ) continue; qbuf.mtype = other_ports[x]; if( msgsnd( qid, &qbuf, strlen( qbuf.mtext ) + 1, 0 ) == -1 ) bug( "%s: errno: %d", __func__, errno ); } }
ip_q open_ipq(const char * name) { return open_queue(name, 46, 256); }