int main(int argc, char *argv[]) { int redemarrage = atoi(argv[7]); int position = atoi(argv[6]); GUI_ARINC_partition("Partition2", position, redemarrage); int nbarg = argc; char **argument = new char*[argc]; int i = 0; for (i = 0; i <= nbarg; i++) { argument[i] = argv[i]; } COMMUNICATION_VECTOR myCvector; myCvector = init_communication(argument, NULL); Type_Message rMessage; int portID; int sock; vector_get(&(myCvector.vqueuing_port), 0, &portID); std::cout << "QueingPort : " << portID << std::endl; vector_get(&(myCvector.vqueuing_socket), 0, &sock); std::cout << "Queuing socket : " << sock << std::endl; // CQueuing Qservice; int ifmessage = 0; int cptMessage = 0; for (ifmessage=0; ifmessage < 10 ; ifmessage++){ char sMessage[256]; std::cout << "Sending queuing message numero " << ifmessage << std::endl; sprintf(sMessage, "Message envoye depuis f2 numero %d", ifmessage); SEND_QUEUING_MESSAGE(argv[0], portID, sock, myCvector.emetteur, sMessage); } for (;;) { // std::cout << "debur boucle for, vqueuing_socket[0] : " << sock << std::endl; ifmessage = RECEIVE_QUEUING_MESSAGE(sock, &rMessage); if (ifmessage > 0) { // Qservice.Display_Message(); std::cout << " " << std::endl; std::cout << "Display message : " << rMessage.m_message << std::endl; std::cout << "length " << rMessage.m_length << std::endl; std::cout << "total length " << sizeof (rMessage) << std::endl; std::cout << "receive :" << rMessage.m_message << std::endl; std::cout << " " << std::endl; }else{ std::cout << "No new queuing message" << std::endl; } sleep(1); } return 0; }
void test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl( Base_Types__Unsigned_32 * the_proc2_p_in_comConnectionLength_len, pok_port_id_t * the_proc2_p_in_comConnectionPortId_port_id, APEX_INTEGER * the_proc2_p_in_cnx_p_in) { RETURN_CODE_TYPE test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_the_cpu2_system_part_comProcess_system_part_comm_runtime_call_ret; common_pkg__Integer test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_p_in_localVariable; SYSTEM_TIME_TYPE test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_p_in_TimeOut = 0; test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_behaviorIdentifier_enum whichPortActivated = test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_behaviorIdentifier_enum_default_behavior; while(1) { switch(the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_current_state) { case test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_BA_entrypoint_init_state: // Transition id: which_behavior_default_mode if(1) // no execution condition { the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_current_state = test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_BA_entrypoint_exec_state; whichPortActivated = test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_behaviorIdentifier_enum_default_behavior; break; } case test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_BA_entrypoint_wait_dispatch_state: // Transition id: dispatch_transition if(1) // no execution condition { the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_current_state = test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_BA_entrypoint_exec_state; PERIODIC_WAIT (&test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_the_cpu2_system_part_comProcess_system_part_comm_runtime_call_ret); break; } case test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_BA_entrypoint_exec_state: // Transition id: the_cpu2_communicationCallSequence -- Priority 0 if(whichPortActivated == test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_behaviorIdentifier_enum_default_behavior) { the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_current_state = test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_BA_entrypoint_wait_dispatch_state; rtl8029_read (*the_proc2_p_in_comConnectionPortId_port_id, &test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_p_in_localVariable, *the_proc2_p_in_comConnectionLength_len); SEND_QUEUING_MESSAGE ((*the_proc2_p_in_cnx_p_in), &test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_p_in_localVariable, *the_proc2_p_in_comConnectionLength_len, test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_p_in_TimeOut, &test_network_rtl8029_remote_communications_refined_model__the_cpu2_system_part_comProcess_system_part_comm_entrypoint_impl_the_cpu2_system_part_comProcess_system_part_comm_runtime_call_ret); break; } } } }
void test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl(APEX_INTEGER * cnx_p_out) { RETURN_CODE_TYPE test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_the_proc1_the_sender_runtime_call_ret; common_pkg__Integer test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_p_out_localVariable; MESSAGE_SIZE_TYPE test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_p_out_Length = sizeof(common_pkg__Integer); SYSTEM_TIME_TYPE test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_p_out_TimeOut = 0; test_queuing_refined_model__the_proc1_the_sender_behaviorIdentifier_enum whichPortActivated = test_queuing_refined_model__the_proc1_the_sender_behaviorIdentifier_enum_default_behavior; while(1) { switch(the_proc1_the_sender_entrypoint_impl_current_state) { case test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_BA_entrypoint_init_state: // Transition id: which_behavior_default_mode if(1) // no execution condition { the_proc1_the_sender_entrypoint_impl_current_state = test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_BA_entrypoint_exec_state; whichPortActivated = test_queuing_refined_model__the_proc1_the_sender_behaviorIdentifier_enum_default_behavior; break; } case test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_BA_entrypoint_wait_dispatch_state: // Transition id: dispatch_transition if(1) // no execution condition { the_proc1_the_sender_entrypoint_impl_current_state = test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_BA_entrypoint_exec_state; PERIODIC_WAIT (&test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_the_proc1_the_sender_runtime_call_ret); break; } case test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_BA_entrypoint_exec_state: // Transition id: call -- Priority 0 if(whichPortActivated == test_queuing_refined_model__the_proc1_the_sender_behaviorIdentifier_enum_default_behavior) { the_proc1_the_sender_entrypoint_impl_current_state = test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_BA_entrypoint_wait_dispatch_state; send (&test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_p_out_localVariable); SEND_QUEUING_MESSAGE ((*cnx_p_out), &test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_p_out_localVariable, test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_p_out_Length, test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_p_out_TimeOut, &test_queuing_refined_model__the_proc1_the_sender_entrypoint_impl_the_proc1_the_sender_runtime_call_ret); break; } } } }
void* thr1_3_job () { RETURN_CODE_TYPE ret; unsigned char val8 = 8; QS_7_msg = &val8; QS_7_msg_size = sizeof(unsigned char); while (1) { printf("Partition n. 1 - Thread n.3\n"); /***************************************************************/ /* Message processing code should be placed here */ /***************************************************************/ SEND_QUEUING_MESSAGE (QS_7_id, QS_7_msg, QS_7_msg_size, 0, &(ret)); printf(" SENT message 0x%x to port 8, size: %d, ret: %d\n", ((unsigned char *)QS_7_msg)[0], QS_7_msg_size, ret); PERIODIC_WAIT (&(ret)); } }
int main(int argc, char *argv[]) { //The simulator isn't able to find the machine name alone, we have to hardcode it char * name_machine = "192.168.1.1"; int nbarg = argc; char **argument = new char*[argc]; int i = 0; for (i = 0; i <= nbarg; i++) { argument[i] = argv[i]; } //Communication initialization COMMUNICATION_VECTOR myCvector; myCvector = init_communication(argument, NULL); int ifmsg = 0; int portID0; int sock0; vector_get(&(myCvector.vqueuing_port), 0, &portID0); vector_get(&(myCvector.vqueuing_socket), 0, &sock0); char sMessage[messageSize]; const int c_takeoff_ms = 4*1000; const int c_land_ms = 3*1000; const int c_interval_ms = 15; const int c_interval_us = c_interval_ms*1000; int sequence = 1; //Keep tracks of number of packet sent //Initialization of the drone char ftrim[] = "AT*FTRIM=1,\r"; sequence++; SEND_QUEUING_MESSAGE(name_machine, portID0, sock0, myCvector.emetteur, ftrim, messageSize); usleep(100*1000); const int c_takeoff = (1<<9)|(1<<18)|(1<<20)|(1<<22)|(1<<24)|(1<<28); const int c_land = (1<<18)|(1<<20)|(1<<22)|(1<<24)|(1<<28); //We have to send several time the same command to be sure that the drone didn't miss it //Take off command for (int i = 0; i < c_takeoff_ms; i+=c_interval_ms) { sprintf(sMessage, "AT*REF=%d,%d\r", sequence++, c_takeoff); SEND_QUEUING_MESSAGE(name_machine, portID0, sock0, myCvector.emetteur, sMessage, messageSize); usleep(c_interval_us); memset(sMessage, 0, 30); } //Landing command for (int i = 0; i < c_land_ms; i+=c_interval_ms) { sprintf(sMessage, "AT*REF=%d,%d\r", sequence++, c_land); SEND_QUEUING_MESSAGE(name_machine, portID0, sock0, myCvector.emetteur, sMessage, messageSize); usleep(c_interval_us); memset(sMessage, 0, 30); } //We put the partition in an infinite loop because the simulator keeps working while(1) { std::cout<<" End of control partition " <<std::endl; } return 0; }
int main(int argc, char *argv[]) { //The simulator isn't able to find the machine name alone, we have to hardcode it char * name_machine = "127.0.0.1"; int nbarg = argc; char **argument = new char*[argc]; int i = 0; Type_Message rMessage; for (i = 0; i <= nbarg; i++) { argument[i] = argv[i]; } printf("Initialisation ARINC653\n"); //Communication initialization COMMUNICATION_VECTOR myCvector; myCvector = init_communication(argument, NULL); int portID; int sock; char messageReceived[256]; char sMessage[256]; char sMessage_rcv[256]; vector_get(&(myCvector.vqueuing_port), 0, &portID); vector_get(&(myCvector.vqueuing_socket), 0, &sock); int INIT_DONE = 0; i = 0; memset(sMessage, 0, 256); #if 1 while(1) { if (RECEIVE_QUEUING_MESSAGE(sock, &rMessage) > 0) { printf("P2 received: %s\n", rMessage.m_message); i++; sprintf(sMessage,"P2 send No %d", i); SEND_QUEUING_MESSAGE(name_machine, portID, sock, myCvector.emetteur, sMessage, sizeof(sMessage)); } else { printf("P2 received nothing\n"); sleep(1); } } #else //drone Msg Control while(RECEIVE_QUEUING_MESSAGE(sock, &rMessage) <= 0) { ; } if(strcmp(rMessage.m_message,"P1 INIT_DONE") == 0) { printf("P2 Beginning of command loop... \n"); } else { printf("p2 failed : Received %s from P1\n", rMessage.m_message); return 0; } sleep(1); msgID = DRONE_MSG_CMD; msgCont = 1; //take off memcpy(sMessage,&msgID, 4); memcpy(sMessage+4, &msgCont, 4); printf("p2 send takeoff cmd = %d\n", msgCont); SEND_QUEUING_MESSAGE(name_machine, portID, sock, myCvector.emetteur, sMessage, sizeof(sMessage)); for (i=0; i<400 ; i++) { if(RECEIVE_QUEUING_MESSAGE(sock, &rMessage)>0) { //TEST memcpy(&msgID, rMessage.m_message, 4); memcpy(&msgCont, rMessage.m_message+4, 4); printf("P2 received msg ID=%d; msgCont=%d\n", msgID, (int)msgCont); switch(msgID) { case DRONE_MSG_ALT: //TEST // memcpy(&msgCont, rMessage.m_message+4, 4); // printf("P2 received height= %d cm\n", (int)msgCont); break; default: break; } } usleep(100000); } msgID = DRONE_MSG_CMD; msgCont = 2; //land memcpy(sMessage,&msgID, 4); memcpy(sMessage+4, &msgCont, 4); SEND_QUEUING_MESSAGE(name_machine, portID, sock, myCvector.emetteur, sMessage, sizeof(sMessage)); while(1) sleep(10); #endif return 0; }