Commit c49e2b19 authored by yoogx's avatar yoogx

* Add fflush(stdout) to force printf, minor reformatting

parent 7e5c5f96
...@@ -12,23 +12,25 @@ __po_hi_storage_file_t myfile_write; ...@@ -12,23 +12,25 @@ __po_hi_storage_file_t myfile_write;
void user_produce_pkts_init () void user_produce_pkts_init ()
{ {
printf ("*** INIT DATA PRODUCER ***\n"); printf ("*** INIT DATA PRODUCER ***\n");
fflush (stdout);
if (__po_hi_storage_file_open (FILENAME, &myfile_write) != __PO_HI_SUCCESS) if (__po_hi_storage_file_open (FILENAME, &myfile_write) != __PO_HI_SUCCESS)
{ {
printf ("*** /!\\ ERROR WHEN OPENING THE FILE %s /!\\ ***\n", FILENAME); printf ("*** /!\\ ERROR WHEN OPENING THE FILE %s /!\\ ***\n", FILENAME);
fflush (stdout);
} }
if (__po_hi_storage_file_create (&myfile_write) != __PO_HI_SUCCESS) if (__po_hi_storage_file_create (&myfile_write) != __PO_HI_SUCCESS)
{ {
printf ("*** /!\\ ERROR WHEN CREATING THE FILE %s /!\\ ***\n", FILENAME); printf ("*** /!\\ ERROR WHEN CREATING THE FILE %s /!\\ ***\n", FILENAME);
fflush (stdout);
} }
if (__po_hi_storage_file_open (FILENAME, &myfile_read) != __PO_HI_SUCCESS) if (__po_hi_storage_file_open (FILENAME, &myfile_read) != __PO_HI_SUCCESS)
{ {
printf ("*** /!\\ ERROR WHEN OPENING THE FILE %s /!\\ ***\n", FILENAME); printf ("*** /!\\ ERROR WHEN OPENING THE FILE %s /!\\ ***\n", FILENAME);
}
fflush (stdout); fflush (stdout);
}
} }
void user_produce_pkts () void user_produce_pkts ()
...@@ -41,6 +43,7 @@ void user_produce_pkts () ...@@ -41,6 +43,7 @@ void user_produce_pkts ()
pkt.port = pinger_global_data_source; pkt.port = pinger_global_data_source;
printf ("*** PRODUCE PKT WITH VALUE *** %d\n", p); printf ("*** PRODUCE PKT WITH VALUE *** %d\n", p);
fflush (stdout);
p++; p++;
ret = __po_hi_storage_file_write (&myfile_write, &pkt, sizeof (__po_hi_request_t)); ret = __po_hi_storage_file_write (&myfile_write, &pkt, sizeof (__po_hi_request_t));
...@@ -48,12 +51,9 @@ void user_produce_pkts () ...@@ -48,12 +51,9 @@ void user_produce_pkts ()
if (ret != __PO_HI_SUCCESS) if (ret != __PO_HI_SUCCESS)
{ {
printf ("*** /!\\ ERROR WHEN WRITING A PACKET IN THE FILE (ret=%d) /!\\ ***\n", ret); printf ("*** /!\\ ERROR WHEN WRITING A PACKET IN THE FILE (ret=%d) /!\\ ***\n", ret);
}
fflush (stdout); fflush (stdout);
} }
}
void user_do_ping_spg () void user_do_ping_spg ()
{ {
...@@ -64,24 +64,22 @@ void user_do_ping_spg () ...@@ -64,24 +64,22 @@ void user_do_ping_spg ()
ret = __po_hi_storage_file_read (&myfile_read, &pkt, sizeof (__po_hi_request_t)); ret = __po_hi_storage_file_read (&myfile_read, &pkt, sizeof (__po_hi_request_t));
if (ret != __PO_HI_SUCCESS) if (ret != __PO_HI_SUCCESS) {
{
printf ("*** /!\\ ERROR WHEN READING A PACKET FROM FILE /!\\ ***\n"); printf ("*** /!\\ ERROR WHEN READING A PACKET FROM FILE /!\\ ***\n");
fflush (stdout);
if (ret == __PO_HI_UNAVAILABLE) if (ret == __PO_HI_UNAVAILABLE) {
{
printf ("*** /!\\ ;_; NO PACKET AVAILABLE AT THIS TIME ;_; /!\\ ***\n"); printf ("*** /!\\ ;_; NO PACKET AVAILABLE AT THIS TIME ;_; /!\\ ***\n");
fflush (stdout);
} }
} } else {
else
{
printf ("*** SENDING PKT *** \n"); printf ("*** SENDING PKT *** \n");
fflush (stdout);
__po_hi_gqueue_store_out (node_a_pinger_k, pinger_local_data_source, &(pkt)); __po_hi_gqueue_store_out (node_a_pinger_k, pinger_local_data_source, &(pkt));
} }
fflush (stdout); fflush (stdout);
} }
void recover (void) void recover (void)
{ {
printf ("*** RECOVER ACTION ***\n"); printf ("*** RECOVER ACTION ***\n");
......
...@@ -10,18 +10,21 @@ void on_req(__po_hi_task_id self) ...@@ -10,18 +10,21 @@ void on_req(__po_hi_task_id self)
__po_hi_request_t request; __po_hi_request_t request;
request.port = landing_gear_global_dummy_out; request.port = landing_gear_global_dummy_out;
printf("=== Starting gear op ===\n"); printf("=== Starting gear op ===\n");
fflush (stdout);
__po_hi_gqueue_store_out(self,landing_gear_local_dummy_out,&request); __po_hi_gqueue_store_out(self,landing_gear_local_dummy_out,&request);
} }
void on_dummy(__po_hi_task_id self) void on_dummy(__po_hi_task_id self)
{ {
printf("=== Starting gear done ===\n"); printf("=== Starting gear done ===\n");
fflush (stdout);
} }
void on_dummy_in(__po_hi_task_id self) void on_dummy_in(__po_hi_task_id self)
{ {
__po_hi_request_t request; __po_hi_request_t request;
printf("=== Gear op done ===\n"); printf("=== Gear op done ===\n");
fflush (stdout);
__po_hi_gqueue_store_out(self,landing_gear_local_ack,&request); __po_hi_gqueue_store_out(self,landing_gear_local_ack,&request);
} }
...@@ -30,16 +33,19 @@ void on_stall_warning (__po_hi_task_id self, int i) ...@@ -30,16 +33,19 @@ void on_stall_warning (__po_hi_task_id self, int i)
if (i==1) if (i==1)
{ {
printf("=== STALL ALARM %d ====\n", i); printf("=== STALL ALARM %d ====\n", i);
fflush (stdout);
} }
else else
{ {
printf("=== False Alert %d ====\n", i); printf("=== False Alert %d ====\n", i);
fflush (stdout);
} }
} }
void on_engine_failure(__po_hi_task_id self) void on_engine_failure(__po_hi_task_id self)
{ {
printf("=== ENGINE FAILURE ALARM ===\n"); printf("=== ENGINE FAILURE ALARM ===\n");
fflush (stdout);
} }
void on_gear_cmd(__po_hi_task_id self) void on_gear_cmd(__po_hi_task_id self)
...@@ -51,6 +57,7 @@ void on_gear_cmd(__po_hi_task_id self) ...@@ -51,6 +57,7 @@ void on_gear_cmd(__po_hi_task_id self)
void on_gear_ack(__po_hi_task_id self) void on_gear_ack(__po_hi_task_id self)
{ {
printf("=== Gear Locked ===\n"); printf("=== Gear Locked ===\n");
fflush (stdout);
} }
void on_operator (__po_hi_task_id self) void on_operator (__po_hi_task_id self)
...@@ -75,6 +82,7 @@ void on_sensor_sim(__po_hi_task_id self) ...@@ -75,6 +82,7 @@ void on_sensor_sim(__po_hi_task_id self)
__po_hi_gqueue_store_out(self,sensor_sim_local_aoa,&request1); __po_hi_gqueue_store_out(self,sensor_sim_local_aoa,&request1);
__po_hi_gqueue_store_out(self,sensor_sim_local_climb_rate,&request2); __po_hi_gqueue_store_out(self,sensor_sim_local_climb_rate,&request2);
printf("=== Sensor Sim setting soft stall ===\n"); printf("=== Sensor Sim setting soft stall ===\n");
fflush (stdout);
} }
else else
{ {
...@@ -85,6 +93,7 @@ void on_sensor_sim(__po_hi_task_id self) ...@@ -85,6 +93,7 @@ void on_sensor_sim(__po_hi_task_id self)
__po_hi_gqueue_store_out(self,sensor_sim_local_aoa,&request1); __po_hi_gqueue_store_out(self,sensor_sim_local_aoa,&request1);
__po_hi_gqueue_store_out(self,sensor_sim_local_climb_rate,&request2); __po_hi_gqueue_store_out(self,sensor_sim_local_climb_rate,&request2);
printf("=== Sensor Sim setting hard stall ===\n"); printf("=== Sensor Sim setting hard stall ===\n");
fflush (stdout);
} }
else else
{ {
...@@ -92,6 +101,7 @@ void on_sensor_sim(__po_hi_task_id self) ...@@ -92,6 +101,7 @@ void on_sensor_sim(__po_hi_task_id self)
{ {
__po_hi_gqueue_store_out(self,sensor_sim_local_engine_failure,&request1); __po_hi_gqueue_store_out(self,sensor_sim_local_engine_failure,&request1);
printf("=== Sensor Sim raising engine failure ===\n"); printf("=== Sensor Sim raising engine failure ===\n");
fflush (stdout);
} }
else else
{ {
......
...@@ -13,9 +13,11 @@ void user_produce_spg (int* data) ...@@ -13,9 +13,11 @@ void user_produce_spg (int* data)
printf ("At time %3lu:%3lu, produce : %d\n", printf ("At time %3lu:%3lu, produce : %d\n",
mytime.tv_sec % 3600, mytime.tv_nsec / 1000000, mytime.tv_sec % 3600, mytime.tv_nsec / 1000000,
produce_data); produce_data);
fflush(stdout);
#else #else
*data = produce_data; *data = produce_data;
printf ("Produce %d\n", *data); printf ("Produce %d\n", *data);
fflush(stdout);
#endif #endif
produce_data++; produce_data++;
} }
...@@ -26,8 +28,10 @@ void user_consume_spg (int data) ...@@ -26,8 +28,10 @@ void user_consume_spg (int data)
struct timespec mytime; struct timespec mytime;
clock_gettime (CLOCK_REALTIME, &mytime); clock_gettime (CLOCK_REALTIME, &mytime);
printf( "At time %3lu:%3lu, consume : %d\n", mytime.tv_sec % 3600 , mytime.tv_nsec/1000000,data); printf( "At time %3lu:%3lu, consume : %d\n", mytime.tv_sec % 3600 , mytime.tv_nsec/1000000,data);
fflush(stdout);
#else #else
printf ("Consume %d\n", data); printf ("Consume %d\n", data);
fflush(stdout);
#endif #endif
} }
...@@ -16,11 +16,13 @@ void user_emit_boolean( int16_t* boolean) ...@@ -16,11 +16,13 @@ void user_emit_boolean( int16_t* boolean)
} }
*boolean = boolean_type_var; *boolean = boolean_type_var;
printf ("Sending boolean : %d\n", *boolean); printf ("Sending boolean : %d\n", *boolean);
fflush (stdout);
} }
void user_receive_boolean (int16_t boolean) void user_receive_boolean (int16_t boolean)
{ {
printf ("Receiving boolean : %d\n", boolean); printf ("Receiving boolean : %d\n", boolean);
fflush (stdout);
} }
void user_emit_integer( int32_t* integer) void user_emit_integer( int32_t* integer)
...@@ -28,9 +30,11 @@ void user_emit_integer( int32_t* integer) ...@@ -28,9 +30,11 @@ void user_emit_integer( int32_t* integer)
integer_type_var++; integer_type_var++;
*integer = integer_type_var; *integer = integer_type_var;
printf ("Emetting integer : %d\n", *integer); printf ("Emetting integer : %d\n", *integer);
fflush (stdout);
} }
void user_receive_integer (int32_t integer) void user_receive_integer (int32_t integer)
{ {
printf ("Receiving integer : %d\n", integer); printf ("Receiving integer : %d\n", integer);
fflush (stdout);
} }
...@@ -16,6 +16,7 @@ void user_sunseekerplant ...@@ -16,6 +16,7 @@ void user_sunseekerplant
float transfer_fcn_update; float transfer_fcn_update;
printf ("PLANT INPUT: %f\n", controller_input); printf ("PLANT INPUT: %f\n", controller_input);
fflush (stdout);
preamp_output = controller_input * (-2.0); preamp_output = controller_input * (-2.0);
integrator_output = plant_integrator; integrator_output = plant_integrator;
plant_output = 0.002 * plant_transfer_fcn; plant_output = 0.002 * plant_transfer_fcn;
...@@ -25,10 +26,9 @@ void user_sunseekerplant ...@@ -25,10 +26,9 @@ void user_sunseekerplant
plant_integrator = plant_integrator + 0.001 * plant_output; plant_integrator = plant_integrator + 0.001 * plant_output;
feedback_error = preamp_output - feedback; feedback_error = preamp_output - feedback;
transfer_fcn_update = 1000000 * feedback_error; transfer_fcn_update = 1000000.0 * feedback_error;
plant_transfer_fcn = plant_transfer_fcn + plant_period * transfer_fcn_update; plant_transfer_fcn = plant_transfer_fcn + plant_period * transfer_fcn_update;
printf ("PLANT OUTPUT: %f ERROR : %f\n", *outputfeedback, feedback_error); printf ("PLANT OUTPUT: %f ERROR : %f\n", *outputfeedback, feedback_error);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment