int main(void) { openRadio(); printf("success\n"); uint8_t header; CRTPPacket p; CRTPPacket* r; uint8_t port=0; uint8_t channel=0; int x; x=scanChannels(); x=getNumberOfMems(); /* for(int x=0;x<1;x++) { x=sendCommander(0.0,0.0,0.0,15000); sleep(1); } sleep(15); */ closeRadio(); return 0; }
void scan::updateChannels(channels *chan) { channels newchannels = scanChannels(); int newsort[(*chan).numberChannels() + newchannels.numberChannels()]; int notfound[newchannels.numberChannels()]; int numbernotfoundchannels = 0; printf("Starting update-Compare\n"); //printf("Old: %d - New: %d\n", (*chan).numberChannels(), newchannels.numberChannels()); for (int i = 0; i < (*chan).numberChannels(); i++) newsort[i] = -1; printf("----> 1\n"); for (int i = 0; i < newchannels.numberChannels(); i++) { printf("%d\n", i); channel tmp_chan = newchannels.getChannelByNumber(i); int chan_num = (*chan).getChannelNumber(tmp_chan.TS, tmp_chan.ONID, tmp_chan.SID); printf("Channel number: %d\n", chan_num); if (chan_num != -1) newsort[chan_num] = i; else { notfound[numbernotfoundchannels++] = i; } } printf("----> 2\n"); for (int i = 0; i < numbernotfoundchannels; i++) { newsort[(*chan).numberChannels() + i] = notfound[i]; } printf("----> 3\n"); channel empty_chan; memset (&empty_chan, 0, sizeof(struct channel)); strcpy(empty_chan.serviceName, "--> Deleted"); printf("Complete: %d\n", (*chan).numberChannels() + numbernotfoundchannels); printf("----> 4\n"); int numbercomplete = (*chan).numberChannels() + numbernotfoundchannels; (*chan).clearChannels(); for (int i = 0; i < numbercomplete; i++) { channel tmp_chan; if (newsort[i] != -1) tmp_chan = newchannels.getChannelByNumber(newsort[i]); else tmp_chan = empty_chan; (*chan).addChannel(tmp_chan); } newchannels.setBeginTS(); for (int i = 0; i < newchannels.numberTransponders(); i++) { printf("Adding Transponder %x\n ONID %x\n Frequency %d\n", newchannels.getCurrentSelectedTS(), newchannels.getCurrentSelectedONID(), newchannels.getCurrentFrequency()); (*chan).addTS(newchannels.getCurrentSelectedTS(), newchannels.getCurrentSelectedONID(), newchannels.getCurrentFrequency(), newchannels.getCurrentSymbolrate(), newchannels.getCurrentPolarization(), newchannels.getCurrentFEC()); newchannels.setNextTS(); } }