kopia lustrzana https://github.com/ogre/pizero_tracker
Merge branch 'master' of github.com:ogre/pizero_tracker
commit
83ab6819a7
|
@ -202,11 +202,14 @@ def StateLoop(port):
|
|||
reply = client.recv()
|
||||
if reply:
|
||||
try:
|
||||
STATE[qm] = json.loads( reply.replace("'", '"') )
|
||||
reply_data = json.loads( reply.replace("'", '"') )
|
||||
STATE[qm] = reply_data
|
||||
# print("reply_data:")
|
||||
# pprint(reply_data)
|
||||
except:
|
||||
pass
|
||||
# print("Can't parse JSON for ", qm)
|
||||
# print(traceback.format_exc())
|
||||
print("Can't parse JSON for ", qm)
|
||||
print(reply)
|
||||
print(traceback.format_exc())
|
||||
expect_reply = False
|
||||
else:
|
||||
break
|
||||
|
@ -394,5 +397,18 @@ def main():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
try:
|
||||
import setproctitle
|
||||
setproctitle.setproctitle('camera.py')
|
||||
except:
|
||||
pass
|
||||
|
||||
while 1:
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
break
|
||||
except:
|
||||
print( traceback.format_exc() )
|
||||
time.sleep(1)
|
||||
# ConvertToSSDV(sys.argv[-2], sys.argv[-1], 512, 'fro', 0)
|
|
@ -155,6 +155,7 @@ int main1(int argc, char** argv)
|
|||
signal(SIGINT, CTRL_C);
|
||||
signal(SIGTERM, CTRL_C);
|
||||
|
||||
|
||||
// RADIO
|
||||
//
|
||||
gpioSetPullUpDown( G.cli.hw_pin_radio_on, PI_PUD_DOWN );
|
||||
|
@ -268,10 +269,20 @@ int main1(int argc, char** argv)
|
|||
});
|
||||
|
||||
|
||||
// read last emited message ID and resume from that number
|
||||
int msg_id = 0;
|
||||
FILE* msgid_fh = fopen("./tracker.msgid", "r");
|
||||
if(msgid_fh) {
|
||||
fscanf(msgid_fh, "%d", &msg_id);
|
||||
fclose(msgid_fh);
|
||||
cout<<"Resume message ID "<<msg_id<<endl;
|
||||
}
|
||||
msgid_fh = fopen("./tracker.msgid", "w");
|
||||
|
||||
|
||||
// READ SENSORS, CONSTRUCT TELEMETRY MESSAGE, RF SEND TELEMETRY AND IMAGE
|
||||
//
|
||||
ssdv_t ssdv_packets;
|
||||
int msg_id = 0;
|
||||
while(G_RUN)
|
||||
{
|
||||
// telemetry. G.cli.msg_num sentences before SSDV
|
||||
|
@ -301,6 +312,12 @@ int main1(int argc, char** argv)
|
|||
// emit telemetry msg @RF
|
||||
//
|
||||
mtx2_write(radio_fd, msg_with_crc + '\n');
|
||||
|
||||
// write last emited message ID
|
||||
if(msgid_fh) {
|
||||
rewind(msgid_fh);
|
||||
fprintf(msgid_fh, "%08d", msg_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -331,6 +348,8 @@ int main1(int argc, char** argv)
|
|||
|
||||
// RELEASE RESOURCES
|
||||
//
|
||||
if(msgid_fh)
|
||||
fclose(msgid_fh);
|
||||
cout<<"Closing sensors thread"<<endl;
|
||||
sensors_thread.join();
|
||||
cout<<"Closing uBlox I2C thread and device"<<endl;
|
||||
|
|
|
@ -16,10 +16,17 @@ size_t ssdv_t::load_file(const std::string file_path)
|
|||
{
|
||||
const size_t read_bytes = fread( tile.data(), 1, sizeof(tile), p_file );
|
||||
if(!read_bytes)
|
||||
return total_tiles;
|
||||
break;
|
||||
tiles_que_.push_back(tile);
|
||||
++total_tiles;
|
||||
}
|
||||
|
||||
if(!total_tiles) { // could not load this file. delete it.
|
||||
std::cout<<"SSDV Failed loading "<<file_path<<std::endl;
|
||||
system( (std::string("rm -f ") + file_path + " || echo \"Can't delete SSDV image.\"").c_str() );
|
||||
}
|
||||
|
||||
return total_tiles;
|
||||
}
|
||||
|
||||
ssdv_t::packet_t ssdv_t::next_packet()
|
||||
|
|
|
@ -289,7 +289,7 @@ std::string nmea_t::json() const
|
|||
|
||||
s<<"{";
|
||||
|
||||
s<<"'utc':"<<utc<<sep;
|
||||
s<<"'utc':'"<<utc<<"'"<<sep;
|
||||
s<<"'lat':"<<lat<<sep;
|
||||
s<<"'lon':"<<lon<<sep;
|
||||
s<<"'alt':"<<alt<<sep;
|
||||
|
@ -307,15 +307,15 @@ std::string nmea_t::json() const
|
|||
if( fix_quality == nmea_t::fix_quality_t::kNoFix )
|
||||
s<<"'Q':'kNoFix'";
|
||||
else if( fix_quality == nmea_t::fix_quality_t::kAutonomous )
|
||||
s<<"'Q:kAutonomous'";
|
||||
s<<"'Q':'kAutonomous'";
|
||||
else if( fix_quality == nmea_t::fix_quality_t::kDifferential )
|
||||
s<<"'Q:kDifferential'";
|
||||
s<<"'Q':'kDifferential'";
|
||||
else if( fix_quality == nmea_t::fix_quality_t::kRtkFixed )
|
||||
s<<"'Q:kRtkFixed'";
|
||||
s<<"'Q':'kRtkFixed'";
|
||||
else if( fix_quality == nmea_t::fix_quality_t::kRtkFloat )
|
||||
s<<"'Q:kRtkFloat'";
|
||||
s<<"'Q':'kRtkFloat'";
|
||||
else if( fix_quality == nmea_t::fix_quality_t::kEstimated )
|
||||
s<<"'Q:kEstimated'";
|
||||
s<<"'Q':'kEstimated'";
|
||||
|
||||
s<<"}";
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue