void app_tftp(char *arg) { struct command_t *commands; struct note_t *note; struct pico_tftp_session *session; int is_server_enabled = 0; int filesize; family = IPV6_MODE ? PICO_PROTO_IPV6 : PICO_PROTO_IPV4; commands = parse_arguments(arg); while (commands) { if (toupper(commands->operation) != 'S') note = transfer_prepare(&session, commands->operation, commands->filename, &commands->server_address, family); switch (commands->operation) { case 'S': case 's': if (!is_server_enabled) { pico_tftp_listen(PICO_PROTO_IPV4, (commands->operation == 'S') ? tftp_listen_cb_opt : tftp_listen_cb); is_server_enabled = 1; } break; case 'T': filesize = get_filesize(commands->filename); if (filesize < 0) { fprintf(stderr, "TFTP: unable to read size of file %s\n", commands->filename); exit(3); } pico_tftp_set_option(session, PICO_TFTP_OPTION_FILE, filesize); start_tx(session, commands->filename, short_be(PICO_TFTP_PORT), cb_tftp_tx_opt, note); break; case 't': start_tx(session, commands->filename, short_be(PICO_TFTP_PORT), cb_tftp_tx, note); break; case 'R': pico_tftp_set_option(session, PICO_TFTP_OPTION_FILE, 0); start_rx(session, commands->filename, short_be(PICO_TFTP_PORT), cb_tftp_rx_opt, note); break; case 'r': start_rx(session, commands->filename, short_be(PICO_TFTP_PORT), cb_tftp_rx, note); } commands = commands->next; } }
void send_ack(uint16_t addr) { //temp_tx_header = tx_buffer.msg.header; set_tx_header(addr, ACK, 0xFF); set_crc_of_tx_buffer(); start_tx(); }
void i8251_device::transmit_clock() { m_txc_count++; if (m_txc_count != m_br_factor) return; m_txc_count = 0; if (is_transmit_register_empty()) { if ((m_status & I8251_STATUS_TX_READY) == 0 && (is_tx_enabled() || (m_flags & I8251_DELAYED_TX_EN) != 0)) start_tx(); else m_status |= I8251_STATUS_TX_EMPTY; update_tx_ready(); update_tx_empty(); } /* if diserial has bits to send, make them so */ if (!is_transmit_register_empty()) { uint8_t data = transmit_register_get_data_bit(); m_txd_handler(data); } #if 0 /* hunt mode? */ /* after each bit has been shifted in, it is compared against the current sync byte */ if (BIT(m_command, 7)) { /* data matches sync byte? */ if (m_data == m_sync_bytes[m_sync_byte_offset]) { /* sync byte matches */ /* update for next sync byte? */ m_sync_byte_offset++; /* do all sync bytes match? */ if (m_sync_byte_offset == m_sync_byte_count) { /* ent hunt mode */ m_command &= ~(1<<7); } } else { /* if there is no match, reset */ m_sync_byte_offset = 0; } } #endif }
void RadioSi446x::ptt_on() { digitalWrite(VCXO_ENABLE_PIN, HIGH); reset(); // turn on the blue LED (GPIO2) to indicate TX char gpio_pin_cfg_command2[] = {0x13, 0x02, 0x02, 0x03, 0x02, 0x08, 0x0b, 0x00}; // Set GPIO2 HIGH; Link NIRQ to CTS; Link SDO to MISO; Max drive strength SendCmdReceiveAnswer(8, 1, gpio_pin_cfg_command2); start_tx(); si446x_powerlevel = 1023; }
void tftp_listen_cb(union pico_address *addr, uint16_t port, uint16_t opcode, char *filename, int32_t len) { struct note_t *note; struct pico_tftp_session *session; printf("TFTP listen callback (BASIC) from remote port %" PRIu16 ".\n", short_be(port)); if (opcode == PICO_TFTP_RRQ) { printf("Received TFTP get request for %s\n", filename); note = transfer_prepare(&session, 't', filename, addr, family); start_tx(session, filename, port, cb_tftp_tx, note); } else if (opcode == PICO_TFTP_WRQ) { printf("Received TFTP put request for %s\n", filename); note = transfer_prepare(&session, 'r', filename, addr, family); start_rx(session, filename, port, cb_tftp_rx, note); } }
void tftp_listen_cb_opt(union pico_address *addr, uint16_t port, uint16_t opcode, char *filename, int32_t len) { struct note_t *note; struct pico_tftp_session *session; int options; uint8_t timeout; int32_t filesize; int ret; printf("TFTP listen callback (OPTIONS) from remote port %" PRIu16 ".\n", short_be(port)); /* declare the options we want to support */ ret = pico_tftp_parse_request_args(filename, len, &options, &timeout, &filesize); if (ret) pico_tftp_reject_request(addr, port, TFTP_ERR_EOPT, "Malformed request"); if (opcode == PICO_TFTP_RRQ) { printf("Received TFTP get request for %s\n", filename); note = transfer_prepare(&session, 'T', filename, addr, family); if (options & PICO_TFTP_OPTION_TIME) pico_tftp_set_option(session, PICO_TFTP_OPTION_TIME, timeout); if (options & PICO_TFTP_OPTION_FILE) { ret = get_filesize(filename); if (ret < 0) { pico_tftp_reject_request(addr, port, TFTP_ERR_ENOENT, "File not found"); return; } pico_tftp_set_option(session, PICO_TFTP_OPTION_FILE, ret); } start_tx(session, filename, port, cb_tftp_tx_opt, note); } else { /* opcode == PICO_TFTP_WRQ */ printf("Received TFTP put request for %s\n", filename); note = transfer_prepare(&session, 'R', filename, addr, family); if (options & PICO_TFTP_OPTION_TIME) pico_tftp_set_option(session, PICO_TFTP_OPTION_TIME, timeout); if (options & PICO_TFTP_OPTION_FILE) pico_tftp_set_option(session, PICO_TFTP_OPTION_FILE, filesize); start_rx(session, filename, port, cb_tftp_rx_opt, note); } }
/*------------------------------------------------- check_for_tx_start -------------------------------------------------*/ void i8251_device::check_for_tx_start() { if (is_tx_enabled() && (m_status & (I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY)) == I8251_STATUS_TX_EMPTY) start_tx(); }
int main(void) { system_init(); rtc_init_counter_mode(); rtc_start(); //test_fec_encoding(); //test_fec_decoding(); button_enable_interrupts(); phy_init(); phy_set_rx_callback(rx_callback); while(1) { if (INTERRUPT_BUTTON1 & interrupt_flags) { interrupt_flags &= ~INTERRUPT_BUTTON1; // led_toggle(1); start_tx(); button_clear_interrupt_flag(); button_enable_interrupts(); } if (INTERRUPT_BUTTON3 & interrupt_flags) { interrupt_flags &= ~INTERRUPT_BUTTON3; if (rtcEnabled) { rtcEnabled = 0; rtc_disable_interrupt(); } else { rtcEnabled = 1; rtc_enable_interrupt(); } button_clear_interrupt_flag(); button_enable_interrupts(); } if (INTERRUPT_RTC & interrupt_flags) { interrupt_flags &= ~INTERRUPT_RTC; led_toggle(0); start_tx(); } if (!phy_is_rx_in_progress() && !phy_is_tx_in_progress()) { start_rx(); } if (phy_is_rx_in_progress()) { led_on(2); } else { led_off(2); } if (phy_is_tx_in_progress()) { led_on(3); } else { led_off(3); } // system_lowpower_mode(4,1); } return 0; }
void send_msg(uint16_t addr, uint16_t type, uint8_t priority) { set_tx_header(addr, type, priority); set_crc_of_tx_buffer(); start_tx(); }