int download_ex(u32 data_length)//Big image and parallel transfer. { thread_t *thr; init_engine_context(&ctx); init_sto_info(&sto_info, FALSE); //no checksum enabled. sto_info.to_write_data_len = data_length; enable_security(&ctx, FALSE); //Modify the security step according to some variable. //set_security_step(&ctx, S_CHECK_ONLY); set_security_step(&ctx, S_CHECK_AND_DOWNLOAD); //now is one step to security download. thr = thread_create("fastboot", write_storage_proc, 0, DEFAULT_PRIORITY, 16*1024); if (!thr) { return -1; } thread_resume(thr); TIME_START; read_usb_proc(&data_length); //wait for write thread end. event_wait(&ctx.thr_end_ev); destroy_engine(&ctx); if(ctx.b_error) { fastboot_fail_wrapper("\n@DOWNLOAD ERROR@"); } else { fastboot_okay(""); } }
int main_subscriber (int argc, const char **argv) { DDS_DataWriterQos wr_qos; DDS_DataReaderQos rd_qos; DDS_ReturnCode_t error; sprintf (user_name, ".pid.%u", getpid ()); DDS_entity_name ("Technicolor Chatroom"); #ifdef DDS_SECURITY if (cert_path || key_path || engine_id) enable_security (); #endif part = DDS_DomainParticipantFactory_create_participant (domain_id, NULL, NULL, 0); if (!part) { printf ("Can't create participant!\r\n"); exit (1); } if (verbose) printf ("DDS Domain Participant created.\r\n"); ts = Vector3_type_new (); if (!ts) { printf ("Can't create vector3 message type!\r\n"); exit (1); } error = DDS_DynamicTypeSupport_register_type (ts, part, "simple_msgs::dds_::Vector3_"); if (error) { printf ("Can't register vector3 message type.\r\n"); exit (1); } if (verbose) printf ("DDS Topic type ('%s') registered.\r\n", "simple_msgs::dds_::Vector3_"); topic = DDS_DomainParticipant_create_topic (part, "imu", "simple_msgs::dds_::Vector3_", NULL, NULL, 0); if (!topic) { printf ("Can't register vector3 message type.\r\n"); exit (1); } if (verbose) printf ("DDS Vector3 Topic created.\r\n"); td = DDS_DomainParticipant_lookup_topicdescription (part, "imu"); if (!td) { printf ("Can't get topicdescription.\r\n"); exit (1); } pub = DDS_DomainParticipant_create_publisher (part, NULL, NULL, 0); if (!pub) { printf ("DDS_DomainParticipant_create_publisher () failed!\r\n"); exit (1); } DDS_Publisher_get_default_datawriter_qos (pub, &wr_qos); #ifdef TRANSIENT_LOCAL wr_qos.durability.kind = DDS_TRANSIENT_LOCAL_DURABILITY_QOS; #endif #ifdef RELIABLE wr_qos.reliability.kind = DDS_RELIABLE_RELIABILITY_QOS; #endif #ifdef KEEP_ALL wr_qos.history.kind = DDS_KEEP_ALL_HISTORY_QOS; wr_qos.history.depth = DDS_LENGTH_UNLIMITED; wr_qos.resource_limits.max_samples_per_instance = HISTORY; wr_qos.resource_limits.max_instances = HISTORY * 10; wr_qos.resource_limits.max_samples = HISTORY * 4; #else wr_qos.history.kind = DDS_KEEP_LAST_HISTORY_QOS; wr_qos.history.depth = HISTORY; #endif /* Create a Data Writer. */ dw = DDS_Publisher_create_datawriter (pub, topic, &wr_qos, NULL, 0); if (!dw) { printf ("Unable to create vector3 message writer.\r\n"); exit (1); } if (verbose) printf ("DDS Vector3 message writer created.\r\n"); sub = DDS_DomainParticipant_create_subscriber (part, NULL, NULL, 0); if (!sub) { printf ("DDS_DomainParticipant_create_subscriber () returned an error!\r\n"); exit (1); } if (verbose) printf ("DDS Subscriber created.\r\n"); DDS_Subscriber_get_default_datareader_qos (sub, &rd_qos); #ifdef TRANSIENT_LOCAL rd_qos.durability.kind = DDS_TRANSIENT_LOCAL_DURABILITY_QOS; #endif #ifdef RELIABLE rd_qos.reliability.kind = DDS_RELIABLE_RELIABILITY_QOS; #endif #ifdef KEEP_ALL rd_qos.history.kind = DDS_KEEP_ALL_HISTORY_QOS; rd_qos.history.depth = DDS_LENGTH_UNLIMITED; rd_qos.resource_limits.max_samples_per_instance = HISTORY; rd_qos.resource_limits.max_instances = HISTORY * 10; rd_qos.resource_limits.max_samples = HISTORY * 4; #else rd_qos.history.kind = DDS_KEEP_LAST_HISTORY_QOS; rd_qos.history.depth = HISTORY; #endif dr = DDS_Subscriber_create_datareader (sub, td, &rd_qos, #ifndef WAITSETS &msg_listener, DDS_DATA_AVAILABLE_STATUS); #else NULL, 0); #endif if (!dr) { printf ("DDS_DomainParticipant_create_datareader () returned an error!\r\n"); exit (1); } if (verbose) printf ("DDS Vector message reader created.\r\n"); #ifdef WAITSETS start_imu_reader (dr); #endif // publisher thread //thread_create (rt2, dds_send_imu, dr); // DDS Debug shell thread do_dds_shell (dw); #ifdef WAITSETS stop_imu_reader (dr); #endif DDS_Publisher_delete_datawriter (pub, dw); usleep (200000); error = DDS_DomainParticipant_delete_contained_entities (part); if (verbose) printf ("DDS Entities deleted (error = %u).\r\n", error); Vector3_type_free (ts); if (verbose) printf ("Vector3 Type deleted.\r\n"); error = DDS_DomainParticipantFactory_delete_participant (part); if (verbose) printf ("DDS Participant deleted (error = %u).\r\n", error); #ifdef DDS_SECURITY if (cert_path || key_path || engine_id) cleanup_security (); #endif return (0); }
int dds_chat_main(int argc, char *argv[]) #endif { DDS_DataWriterQos wr_qos; DDS_DataReaderQos rd_qos; DDS_ReturnCode_t error; struct in_addr addr; /* Configure the network */ /* Set up our host address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_IPADDR); netlib_sethostaddr("eth0", &addr); /* Set up the default router address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_DRIPADDR); netlib_setdraddr("eth0", &addr); /* Setup the subnet mask */ addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_NETMASK); netlib_setnetmask("eth0", &addr); /* Start the application */ printf("Network configured, starting DDS chat:\n"); sprintf (user_name, ".pid.%u", getpid ()); do_switches (argc, argv); if (verbose > 1) DDS_Log_stdio (1); DDS_entity_name ("ROS 2.0 embedded"); #ifdef DDS_SECURITY if (cert_path || key_path || engine_id) enable_security (); #endif part = DDS_DomainParticipantFactory_create_participant (domain_id, NULL, NULL, 0); if (!part) { printf ("Can't create participant!\r\n"); exit (1); } if (verbose) printf ("DDS Domain Participant created.\r\n"); ts = ChatMsg_type_new (); if (!ts) { printf ("Can't create chat message type!\r\n"); exit (1); } error = DDS_DynamicTypeSupport_register_type (ts, part, "ChatMsg"); if (error) { printf ("Can't register chat message type.\r\n"); exit (1); } if (verbose) printf ("DDS Topic type ('%s') registered.\r\n", "ChatMsg"); topic = DDS_DomainParticipant_create_topic (part, "Chat", "ChatMsg", NULL, NULL, 0); if (!topic) { printf ("Can't register chat message type.\r\n"); exit (1); } if (verbose) printf ("DDS ChatMsg Topic created.\r\n"); td = DDS_DomainParticipant_lookup_topicdescription (part, "Chat"); if (!td) { printf ("Can't get topicdescription.\r\n"); exit (1); } pub = DDS_DomainParticipant_create_publisher (part, NULL, NULL, 0); if (!pub) { printf ("DDS_DomainParticipant_create_publisher () failed!\r\n"); exit (1); } DDS_Publisher_get_default_datawriter_qos (pub, &wr_qos); #ifdef TRANSIENT_LOCAL wr_qos.durability.kind = DDS_TRANSIENT_LOCAL_DURABILITY_QOS; #endif #ifdef RELIABLE wr_qos.reliability.kind = DDS_RELIABLE_RELIABILITY_QOS; #endif #ifdef KEEP_ALL wr_qos.history.kind = DDS_KEEP_ALL_HISTORY_QOS; wr_qos.history.depth = DDS_LENGTH_UNLIMITED; wr_qos.resource_limits.max_samples_per_instance = HISTORY; wr_qos.resource_limits.max_instances = HISTORY * 10; wr_qos.resource_limits.max_samples = HISTORY * 4; #else wr_qos.history.kind = DDS_KEEP_LAST_HISTORY_QOS; wr_qos.history.depth = HISTORY; #endif /* Create a Data Writer. */ dw = DDS_Publisher_create_datawriter (pub, topic, &wr_qos, NULL, 0); if (!dw) { printf ("Unable to create chat message writer.\r\n"); exit (1); } if (verbose) printf ("DDS Chat message writer created.\r\n"); sub = DDS_DomainParticipant_create_subscriber (part, NULL, NULL, 0); if (!sub) { printf ("DDS_DomainParticipant_create_subscriber () returned an error!\r\n"); exit (1); } if (verbose) printf ("DDS Subscriber created.\r\n"); DDS_Subscriber_get_default_datareader_qos (sub, &rd_qos); #ifdef TRANSIENT_LOCAL rd_qos.durability.kind = DDS_TRANSIENT_LOCAL_DURABILITY_QOS; #endif #ifdef RELIABLE rd_qos.reliability.kind = DDS_RELIABLE_RELIABILITY_QOS; #endif #ifdef KEEP_ALL rd_qos.history.kind = DDS_KEEP_ALL_HISTORY_QOS; rd_qos.history.depth = DDS_LENGTH_UNLIMITED; rd_qos.resource_limits.max_samples_per_instance = HISTORY; rd_qos.resource_limits.max_instances = HISTORY * 10; rd_qos.resource_limits.max_samples = HISTORY * 4; #else rd_qos.history.kind = DDS_KEEP_LAST_HISTORY_QOS; rd_qos.history.depth = HISTORY; #endif dr = DDS_Subscriber_create_datareader (sub, td, &rd_qos, #ifndef WAITSETS &msg_listener, DDS_DATA_AVAILABLE_STATUS); #else NULL, 0); #endif if (!dr) { printf ("DDS_DomainParticipant_create_datareader () returned an error!\r\n"); exit (1); } if (verbose) printf ("DDS Chat message reader created.\r\n"); #ifdef WAITSETS start_chat_reader (dr); #endif do_chat (dw); #ifdef WAITSETS stop_chat_reader (dr); #endif DDS_Publisher_delete_datawriter (pub, dw); usleep (200000); error = DDS_DomainParticipant_delete_contained_entities (part); if (verbose) printf ("DDS Entities deleted (error = %u).\r\n", error); ChatMsg_type_free (ts); if (verbose) printf ("Chat Type deleted.\r\n"); error = DDS_DomainParticipantFactory_delete_participant (part); if (verbose) printf ("DDS Participant deleted (error = %u).\r\n", error); #ifdef DDS_SECURITY if (cert_path || key_path || engine_id) cleanup_security (); #endif return (0); }