From 5979691171d529ef9ae3c02f70b6530e6a0eff1d Mon Sep 17 00:00:00 2001 From: c vw Date: Wed, 17 Jul 2019 16:33:33 +0200 Subject: [PATCH] Small Corrections --- iambic.c | 3 ++- new_discovery.c | 2 +- old_discovery.c | 4 ++-- old_protocol.c | 18 +++--------------- property.c | 23 +++++++++++++---------- 5 files changed, 21 insertions(+), 29 deletions(-) diff --git a/iambic.c b/iambic.c index 3609ee3..dae4e29 100644 --- a/iambic.c +++ b/iambic.c @@ -702,7 +702,8 @@ int keyer_init() { running = 1; #ifdef __APPLE__ - cw_event=sem_open("CW", O_CREAT, 0700, 0); + sem_unlink("CW"); + cw_event=sem_open("CW", O_CREAT | O_EXCL), 0700, 0); rc = (cw_event == SEM_FAILED); #else rc = sem_init(&cw_event, 0, 0); diff --git a/new_discovery.c b/new_discovery.c index 3fed57e..67b95ce 100644 --- a/new_discovery.c +++ b/new_discovery.c @@ -171,7 +171,7 @@ void new_discover(struct ifaddrs* iface) { if(sendto(discovery_socket,buffer,60,0,(struct sockaddr*)&to_addr,sizeof(to_addr))<0) { perror("new_discover: sendto socket failed for discovery_socket\n"); - exit(-1); + return; } // wait for receive thread to complete diff --git a/old_discovery.c b/old_discovery.c index c5a7159..8517d84 100644 --- a/old_discovery.c +++ b/old_discovery.c @@ -162,7 +162,7 @@ static void discover(struct ifaddrs* iface) { interface_addr.sin_port = htons(0); // system assigned port if(bind(discovery_socket,(struct sockaddr*)&interface_addr,sizeof(interface_addr))<0) { perror("discover: bind socket failed for discovery_socket:"); - exit(-1); + return; } fprintf(stderr,"discover: bound to %s\n",interface_name); @@ -208,7 +208,7 @@ static void discover(struct ifaddrs* iface) { if(sendto(discovery_socket,buffer,len,0,(struct sockaddr*)&to_addr,sizeof(to_addr))<0) { perror("discover: sendto socket failed for discovery_socket:"); - exit(-1); + return; } // wait for receive thread to complete diff --git a/old_protocol.c b/old_protocol.c index b830416..01c300d 100644 --- a/old_protocol.c +++ b/old_protocol.c @@ -960,7 +960,7 @@ void ozy_send_buffer() { // the feedback signal is routed automatically/internally // If feedback is to the second ADC, leave RX1 ANT settings untouched // - if (isTransmitting() && transmitter->puresignal && receiver[PS_RX_FEEDBACK]->adc == 0) i=receiver[PS_RX_FEEDBACK]->alex_antenna; + if (isTransmitting() && transmitter->puresignal) i=receiver[PS_RX_FEEDBACK]->alex_antenna; #endif switch(i) { case 3: // Alex: RX2 IN, ANAN: EXT1, ANAN7000: still uses internal feedback @@ -1224,10 +1224,8 @@ void ozy_send_buffer() { output_buffer[C1]|=receiver[0]->adc; // RX1 bound to ADC of first receiver output_buffer[C1]|=(receiver[1]->adc<<2); // RX2 actually unsused with PURESIGNAL output_buffer[C1]|=receiver[1]->adc<<4; // RX3 bound to ADC of second receiver - output_buffer[C1]|=(receiver[PS_RX_FEEDBACK]->adc<<6); // RX4 is PS_RX_Feedbacka - // Usually ADC0, but if feedback is to - // RX2 input it must be ADC1 (see ps_menu.c) - // RX5 is hard-wired to the TX DAC and needs no ADC setting. + // RX4 is PS_RX_Feedback and bound to ADC0 + // RX5 is hard-wired to the TX DAC and needs no ADC setting. } #else output_buffer[C1]|=receiver[0]->adc; @@ -1277,16 +1275,6 @@ void ozy_send_buffer() { output_buffer[C1]=0x00; if(isTransmitting()) { -#ifdef PURESIGNAL - // If we are using the RX2 jack for PURESIGNAL RX feedback, then we MUST NOT ground - // the ADC2 input upon TX. - if (transmitter->puresignal && receiver[PS_RX_FEEDBACK]->adc == 1) { - // Note that this statement seems to have no effect since - // one cannot goto to "manual filter setting" for the ALEX2 board individually - output_buffer[C1]|=0x40; // Set ADC2 filter board to "ByPass" - } else -#endif - output_buffer[C1]|=0x80; // ground RX2 on transmit, bit0-6 are Alex2 filters } output_buffer[C2]=0x00; diff --git a/property.c b/property.c index 67abcbe..08f74af 100644 --- a/property.c +++ b/property.c @@ -47,16 +47,19 @@ void loadProperties(char* filename) { if(string[0]!='#') { name=strtok(string,"="); value=strtok(NULL,"\n"); - property=malloc(sizeof(PROPERTY)); - property->name=malloc(strlen(name)+1); - strcpy(property->name,name); - property->value=malloc(strlen(value)+1); - strcpy(property->value,value); - property->next_property=properties; - properties=property; - if(strcmp(name,"property_version")==0) { - version=atof(value); - } + // Beware of "illegal" lines in corrupted files + if (name != NULL && value != NULL) { + property=malloc(sizeof(PROPERTY)); + property->name=malloc(strlen(name)+1); + strcpy(property->name,name); + property->value=malloc(strlen(value)+1); + strcpy(property->value,value); + property->next_property=properties; + properties=property; + if(strcmp(name,"property_version")==0) { + version=atof(value); + } + } } } fclose(f); -- 2.45.2