![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
LEX_Threaded_Programming
Dependencies: Heater_V2 MODSERIAL Nanopb FastPWM ADS8568_ADC
Diff: main.cpp
- Revision:
- 21:1f233639f0ce
- Parent:
- 17:d86e749ae9be
diff -r d86e749ae9be -r 1f233639f0ce main.cpp --- a/main.cpp Fri Sep 20 14:54:15 2019 +0000 +++ b/main.cpp Mon Sep 23 12:39:34 2019 +0000 @@ -119,15 +119,16 @@ void read_message() { - if (pc.scanf("%d",&message_length) < 0){pc.printf("# Error reading message length");} + if (pc.scanf("%d",&message_length) < 0){pc.printf("[ERROR] Error reading message length");} size_t buffer_length = sizeof(buffer); if (message_length > buffer_length) { - pc.printf("# Message length exceeds buffer. \n Input configuration file\n"); + pc.printf("[ERROR] Message length exceeds buffer. \n Input configuration file\n"); + pc.printf("[CONFIG] Input configuration file\n"); read_message(); return; } - pc.printf("# Message is %d chars long, buffer length is %d\n",message_length,buffer_length); + pc.printf("Message is %d chars long, buffer length is %d\n",message_length,buffer_length); unsigned int c; for (int i = 0; i < message_length; i++) { @@ -146,7 +147,7 @@ // Check for errors... if (!status) { - pc.printf("# Decoding failed: %s\n", PB_GET_ERROR(&istream)); + pc.printf("[ERROR] Decoding failed: %s\n", PB_GET_ERROR(&istream)); } } @@ -157,7 +158,7 @@ status = pb_decode(stream, memspcr_ThermalStep_fields, & result); if (!status) { - pc.printf("# Decode callback failed\n"); + pc.printf("[ERROR] Decode callback failed\n"); } dest->push_back(result); //CHECK: Does result get copied into the vector? @@ -232,7 +233,7 @@ vector <memspcr_ThermalStep>::iterator it_prev, it = profile.begin(); if (it->elapsed_time_ms != 0) { - pc.printf("# Error: the first point in the profile should be at time 0.\n"); + pc.printf("[ERROR] The first point in the profile should be at time 0.\n"); return; } it++; @@ -280,10 +281,10 @@ } if (i_board != -1) pc.printf("Drive board: Board %d\n",drive_board_serial_number[i_board]); - else pc.printf("Drive board UID match not found\n"); + else pc.printf("[ERROR] Drive board UID match not found\n"); buffer_length = sizeof(buffer)/sizeof(uint8_t); - pc.printf("# Input configuration file\n"); + pc.printf("[CONFIG] Input configuration file\n"); //set up nanopb std::vector<memspcr_ThermalStep> profile; @@ -293,9 +294,9 @@ //read and decode configuration read_message(); - pc.printf("# Message read\n"); + pc.printf("Message read\n"); decode_message(); - pc.printf("# Message decoded\n"); + pc.printf("Message decoded\n"); Heater * heater_main = new Heater(i_port_main, v_port_main, & drive_main, & guard_main, & adc, adc_busy, exp_config.thermal); Heater * heater_lysis = new Heater(i_port_lysis, v_port_lysis, & drive_lysis, & guard_lysis, & adc, adc_busy, exp_config.thermal); @@ -308,7 +309,7 @@ heater = heater_lysis; heater_ID = heater_ID_lysis; } else { - pc.printf("# Error - no heater has been selected\n"); + pc.printf("[ERROR] No heater has been selected\n"); return 1; } @@ -317,7 +318,7 @@ for (int i=0; i<2; i++) drive_cal[i] = drive_board_cal[i_board][heater_ID-1][i]; else { drive_cal[0] = 0.0; - drive_cal[1] = 1.0; + drive_cal[1] = 10.0; } pc.printf("Heater: %d drive_cal[0]: %10.6f drive_cal[1]: %10.6f\n", heater_ID, drive_cal[0], drive_cal[1]); @@ -326,20 +327,20 @@ pressure_thread.start(& pressure_control); pressure_tick.attach_us(& pressure_trigger, 500000); - pc.printf("# Waiting for start signal to begin temperature control (type in an s or press button 0)\n"); + pc.printf("[START] Waiting for start signal to begin temperature control (type in an s or press button 0)\n"); heater->Set_ref(0.0); heater_control.start(& temp_control); heat_tick.attach_us(& temp_trigger,exp_config.thermal.control_loop_interval_ms * 1000); while (pc.getcNb()!='s' && !user_0); - pc.printf("# Start signal received\n"); + pc.printf("Start signal received\n"); logging_thread.start(& log_state); log_tick.attach_us(& log_trigger,exp_config.logging_interval_ms * 1000); - pc.printf("# Starting routine\n"); - pc.printf("# heater, time(ms), r, rSet, pIn, pOut\n"); + pc.printf("Starting routine\n"); + pc.printf("heater, time(ms), r, rSet, pIn, pOut\n"); timer.start(); set_point_routine(profile);