some formatting

master
Michal Fratczak 2020-04-03 01:26:46 +02:00
rodzic 4475d8e5d8
commit 279ae9e778
3 zmienionych plików z 8 dodań i 24 usunięć

Wyświetl plik

@ -27,8 +27,10 @@ std::vector<std::string> get_dir_content(const std::string dir)
return ret;
}
} // ns
std::string find_ds18b20_device(const std::string& base_dir) // "/sys/bus/w1/devices/"
{
using namespace std;
@ -52,7 +54,6 @@ float read_temp_from_ds18b20(const std::string& device)
8a 01 4b 46 7f ff 06 10 2c t=24625
*/
vector<string> file_lines;
string line;
while ( getline (ds18b20_file,line) )

Wyświetl plik

@ -50,8 +50,6 @@ std::vector<char> uBLOX_read_msg(int fd, int usec_sleep)
thread_local int buff_i = 0;
thread_local int buff_o = 0;
// auto msg_found_time = time_now();
while( res_str_i < sizeof(res_str) )
{
if( buff_i == buff_o ) // all buffer was scanned since last call
@ -88,9 +86,6 @@ std::vector<char> uBLOX_read_msg(int fd, int usec_sleep)
continue;
}
// cout<<time_duration_mill(msg_found_time)<<" ms"<<endl;
// msg_found_time = time_now();
// copy to output buffer
while(buff_i < buff_o)
{
@ -124,10 +119,7 @@ bool uBLOX_write_msg_ack(int fd, uint8_t* p_msg, size_t msg_sz, const size_t wai
int written_bytes = write(fd, p_msg, msg_sz);
if(written_bytes != msg_sz)
{
// cerr<<"uBLOX_write_msg_ack: wrong bytes numer written: "<<written_bytes<<" of expected "<<msg_sz<<endl;
return false;
}
unique_ptr<uint8_t[]> ack_packet( new uint8_t[10] );
UBX_MAKE_PACKET_ACK( p_msg[2], p_msg[3], ack_packet.get() );
@ -141,21 +133,14 @@ bool uBLOX_write_msg_ack(int fd, uint8_t* p_msg, size_t msg_sz, const size_t wai
vector<char> result_msg = uBLOX_read_msg(fd, 0); // no sleep, we can't miss any message
if( UBX_PACKET_EQ(result_msg, ack_packet.get(), 10) )
{
cout<<"uBLOX ACK 0x"<<hex<<int(p_msg[2])<<" 0x"<<int(p_msg[3])<<dec<<endl;
return true;
}
if( UBX_PACKET_EQ(result_msg, nak_packet.get(), 10) )
{
cout<<"uBLOX NAK 0x"<<hex<<int(p_msg[2])<<" 0x"<<int(p_msg[3])<<dec<<endl;
return false;
}
// cerr<<"uBLOX_write_msg_ack: some other message"<<endl;
}
cout<<"uBLOX no ACK 0x"<<hex<<int(p_msg[2])<<" 0x"<<int(p_msg[3])<<dec<<endl;
return false;
}
@ -169,5 +154,3 @@ std::string vec2str(std::vector<char> v)
return res;
}

Wyświetl plik

@ -84,14 +84,14 @@ uint8_t UBX_CMD_VTG_OFF[] = {
void UBX_CHECKSUM(uint8_t* Buffer, const size_t BufferSz, uint8_t* CK_A, uint8_t* CK_B)
void UBX_CHECKSUM(uint8_t* buffer, const size_t buffer_sz, uint8_t* ck_a, uint8_t* ck_b)
{
*CK_A = 0;
*CK_B = 0;
for(size_t i=0; i<BufferSz; ++i)
*ck_a = 0;
*ck_b = 0;
for(size_t i=0; i<buffer_sz; ++i)
{
*CK_A += Buffer[i];
*CK_B += *CK_A;
*ck_a += buffer[i];
*ck_b += *ck_a;
}
}