int main (void) { init(); #if SERIAL_PROTOCOL == PROTOCOL_KISS while (true) { ax25_poll(&AX25); if (serial_available(0)) { char sbyte = uart0_getchar_nowait(); kiss_serialCallback(sbyte); } } #endif #if SERIAL_PROTOCOL == PROTOCOL_SIMPLE_SERIAL ticks_t start = timer_clock(); while (1) { ax25_poll(&AX25); if (!sertx && serial_available(0)) { sbyte = uart0_getchar_nowait(); #if SERIAL_DEBUG if ((serialLen < AX25_MAX_FRAME_LEN) && (sbyte != 10)) { serialBuffer[serialLen] = sbyte; serialLen++; } else { sertx = true; } #else if (serialLen < AX25_MAX_FRAME_LEN-1) { serialBuffer[serialLen] = sbyte; serialLen++; } else { serialBuffer[serialLen] = sbyte; serialLen++; sertx = true; } start = timer_clock(); #endif } else { if (!SERIAL_DEBUG && serialLen > 0 && timer_clock() - start > ms_to_ticks(TX_MAXWAIT)) { sertx = true; } } if (sertx) { ss_serialCallback(serialBuffer, serialLen, &AX25); sertx = false; serialLen = 0; } } #endif return(0); }
int afsk_testRun(void) { int c; while ((c = fgetc(fp_adc)) != EOF) { afsk_adc_isr (&afsk_fd, (uint8_t) c); ax25_poll(&ax25); } kprintf("Messages correctly received: %d\n", msg_cnt); ASSERT(msg_cnt >= 15); char buf[256]; // start from 1 and then wrap round to 0 otherwise null termination prevents display of data for (unsigned i = 0; i < sizeof (buf); i++) buf[i] = i + 1; ax25_send(&ax25, AX25_CALL("abcdef", 0), AX25_CALL("123456", 1), buf, sizeof(buf)); do { int8_t val = afsk_dac_isr(&afsk_fd) - 128; ASSERT(fwrite(&val, 1, sizeof(val), fp_dac) == sizeof(val)); data_written++; } while (afsk_fd.sending); #define SND_DATASIZE_OFF 8 #if CPU_AVR #warning TODO: fseek? #else ASSERT(fseek(fp_dac, SND_DATASIZE_OFF, SEEK_SET) == 0); #endif data_written = cpu_to_be32(data_written); ASSERT(fwrite(&data_written, 1, sizeof(data_written), fp_dac) == sizeof(data_written)); ASSERT(fclose(fp_adc) + fclose(fp_dac) == 0); fp_adc = afsk_fileOpen("test/afsk_test_out.au"); ax25_init(&ax25, &afsk_fd.fd, messageout_hook); while ((c = fgetc(fp_adc)) != EOF) { afsk_adc_isr(&afsk_fd, (int8_t)c); ax25_poll(&ax25); } return 0; }
int main(void) { init(); ticks_t start = timer_clock(); unsigned char x = 0; // FIXME memcpy(path[1].call, MYCALL, 6); path[1].ssid = MYCALL_SSID; while (1) { /* As long as CONFIG_AFSK_RXTIMEOUT is set to 0, this function won't block and return immediately. */ ax25_poll(&ax25); #if 1 /* Send out message every 15sec */ if (timer_clock() - start > ms_to_ticks(APRS_BEACON_TIME * 1000L)) { kfile_printf(&ser.fd, "Beep %d\n", x++); start = timer_clock(); ax25_sendVia(&ax25, path, countof(path), APRS_BEACON_MSG, sizeof(APRS_BEACON_MSG)); } #endif } return 0; }
int main(void) { init(); LOG_INFO("\r\n== BeRTOS TNC\r\n"); LOG_INFO("== Starting.\r\n"); kfile_printf(&ser_port.fd, "\r\n== BeRTOS TNC\r\n"); kfile_printf(&ser_port.fd, "== Starting.\r\n" ); while (1) { ax25_poll(&ax25); if (ax25.dcd) { LED_BLUE_ON(); } else { LED_BLUE_OFF(); } if (afsk.sending) { LED_GREEN_ON(); } else { LED_GREEN_OFF(); } kiss_serial_poll(); kiss_queue_process(); } return 0; }
int main (void) { init(); while (true) { ax25_poll(&AX25); digipeater_processPackets(); if (serial_available(0)) { //char sbyte = uart0_getchar_nowait(); // Do something with the data :) } } return(0); }
void kiss_csma(AX25Ctx *ctx, uint8_t *buf, size_t len) { bool sent = false; while (!sent) { //puts("Waiting in CSMA"); if(!channel->hdlc.receiving) { uint8_t tp = rand() & 0xFF; if (tp < p) { ax25_sendRaw(ctx, buf, len); sent = true; } else { ticks_t start = timer_clock(); long slot_ticks = ms_to_ticks(slotTime); while (timer_clock() - start < slot_ticks) { cpu_relax(); } } } else { while (!sent && channel->hdlc.receiving) { // Continously poll the modem for data // while waiting, so we don't overrun // receive buffers ax25_poll(ax25ctx); if (channel->status != 0) { // If an overflow or other error // occurs, we'll back off and drop // this packet silently. channel->status = 0; sent = true; } } } } }
int main(void) { init(); ticks_t start = timer_clock(); while (1) { /* * This function will look for new messages from the AFSK channel. * It will call the message_callback() function when a new message is received. * If there's nothing to do, this function will call cpu_relax() */ ax25_poll(&ax25); /* Send out message every 15sec */ if (timer_clock() - start > ms_to_ticks(15000L)) { start = timer_clock(); ax25_sendVia(&ax25, path, countof(path), APRS_MSG, sizeof(APRS_MSG)); } } return 0; }
int main(void) { // Start by running the main initialization init(); // Record the current tick count for time-keeping ticks_t start = timer_clock(); // Go into ye good ol' infinite loop while (1) { // First we instruct the protocol to check for // incoming data ax25_poll(&ax25); // Poll for incoming serial data if (!sertx && ser_available(&ser)) { // We then read a byte from the serial port. // Notice that we use "_nowait" since we can't // have this blocking execution until a byte // comes in. sbyte = ser_getchar_nowait(&ser); // If SERIAL_DEBUG is specified we'll handle // serial data as direct human input and only // transmit when we get a LF character #if SERIAL_DEBUG // If we have not yet surpassed the maximum frame length // and the byte is not a "transmit" (newline) character, // we should store it for transmission. if ((serialLen < CONFIG_AX25_FRAME_BUF_LEN) && (sbyte != 10)) { // Put the read byte into the buffer; serialBuffer[serialLen] = sbyte; // Increment the read length counter serialLen++; } else { // If one of the above conditions were actually the // case, it means we have to transmit, se we set // transmission flag to true. sertx = true; } #else // Otherwise we assume the modem is running // in automated mode, and we push out data // as it becomes available. We either transmit // immediately when the max frame length has // been reached, or when we get no input for // a certain amount of time. if (serialLen < CONFIG_AX25_FRAME_BUF_LEN-1) { // Put the read byte into the buffer; serialBuffer[serialLen] = sbyte; // Increment the read length counter serialLen++; } else { // If max frame length has been reached // we need to transmit. serialBuffer[serialLen] = sbyte; serialLen++; sertx = true; } start = timer_clock(); #endif } else { if (!SERIAL_DEBUG && serialLen > 0 && timer_clock() - start > ms_to_ticks(TX_MAXWAIT)) { sertx = true; } } if (sertx) { ss_serialCallback(serialBuffer, serialLen, &ser, &ax25); sertx = false; serialLen = 0; } } return 0; }
int main(void){ init(); while (1){ /* * This function will look for new messages from the AFSK channel. * It will call the message_callback() function when a new message is received. * If there's nothing to do, this function will call cpu_relax() */ ax25_poll(&g_ax25); check_run_mode(); switch(currentMode){ case MODE_CFG: #if MOD_CONSOLE console_poll(); #endif #if MOD_BEACON beacon_broadcast_poll(); #endif break; #if MOD_TRACKER case MODE_TRACKER: tracker_poll(); break; #endif #if MOD_KISS case MODE_KISS:{ kiss_poll(); break; } #endif #if MOD_DIGI case MODE_DIGI:{ console_poll(); beacon_broadcast_poll(); break; } #endif default: break; }// end of switch(runMode) #if DEBUG_FREE_RAM { static ticks_t ts = 0; if(timer_clock_unlocked() - ts > ms_to_ticks(5000)){ ts = timer_clock_unlocked(); uint16_t ram = freeRam(); SERIAL_PRINTF((&g_serial),"%u\r\n",ram); } } #endif #if DEBUG_SOFT_SER // Dump the isr changes { SoftSerial *softSer = radioPort; static uint32_t i = 0; //static uint32_t j = 0; if(i++ == 30000){ i = 0; char c; while(softser_avail(softSer)){ c = softser_read(softSer); kfile_putc(c,&(g_serial.fd)); } char buf[8]; sprintf_P(buf,PSTR("0K\n\r")); softser_print(softSer,buf); } } #endif } // end of while(1) return 0; }