hci_dump: log sco to stdout, use O_BINART and 0755 file permission on win32

This commit is contained in:
Matthias Ringwald 2017-01-09 15:53:45 +01:00
parent 83f31aa4d7
commit 1e15430263

View File

@ -107,12 +107,15 @@ void hci_dump_open(const char *filename, hci_dump_format_t format){
dump_file = fileno(stdout);
} else {
# ifdef _WIN32
dump_file = open(filename, O_WRONLY | O_CREAT | O_TRUNC);
# else
dump_file = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
# endif
int oflags = O_WRONLY | O_CREAT | O_TRUNC;
#ifdef _WIN32
oflags |= O_BINARY;
#endif
dump_file = open(filename, oflags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
if (dump_file < 0){
printf("hci_dump_open: failed to open file %s\n", filename);
}
}
#else
dump_file = 1;
@ -140,6 +143,13 @@ static void printf_packet(uint8_t packet_type, uint8_t in, uint8_t * packet, uin
printf("ACL => ");
}
break;
case HCI_SCO_DATA_PACKET:
if (in) {
printf("SCO <= ");
} else {
printf("SCO => ");
}
break;
case LOG_MESSAGE_PACKET:
printf("LOG -- %s\n", (char*) packet);
return;
@ -163,7 +173,7 @@ static void printf_timestamp(void){
}
#endif
void hci_dump_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len) {
void hci_dump_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len) {
if (dump_file < 0) return; // not activated yet