static int debug_input_flush_fn(debug_info_t * id, struct debug_view *view, struct file *file, const char __user *user_buf, size_t user_len, loff_t * offset) { char input_buf[1]; int rc = user_len; if (user_len > 0x10000) user_len = 0x10000; if (*offset != 0){ rc = -EPIPE; goto out; } if (copy_from_user(input_buf, user_buf, 1)){ rc = -EFAULT; goto out; } if(input_buf[0] == '-') { debug_flush(id, DEBUG_FLUSH_ALL); goto out; } if (isdigit(input_buf[0])) { int area = ((int) input_buf[0] - (int) '0'); debug_flush(id, area); goto out; } printk(KERN_INFO "debug: area `%c` is not valid\n", input_buf[0]); out: *offset += user_len; return rc; /* number of input characters */ }
void telemetry_init(void) { debug("telemetry: init\n"); debug_flush(); // mark as invalid telemetry_expected_id = 0; // setup buffer telemetry_buffer.write = 0; telemetry_buffer.read = 0; telemetry_buffer.read_ok = 0; #ifdef HUB_TELEMETRY_ON_SBUS_UART // re-use sbus uart, no init necessary debug("telemetry: using sbus uart\n"); debug_flush(); // attach callback uart_set_rx_callback(&telemetry_rx_callback); #else // init software serial port soft_serial_init(); // attach callback soft_serial_set_rx_callback(&telemetry_rx_callback); #endif #if TELEMETRY_DO_TEST telemetry_rx_echo_test(); #endif }
static uint32_t hal_storage_i2c_write_buffer(uint8_t address, uint8_t *buffer, uint8_t len) { if (HAL_STORAGE_I2C_DEBUG) { debug("hal_storage: i2c write_buffer(0x"); debug_put_hex8(address>>8); debug_put_hex8(address&0xFF); debug(", ..., "); debug_put_uint16(len); debug(")\n"); debug_flush(); } uint8_t i; // check for out of bound condition uint16_t last_byte = (uint16_t)address + (uint16_t) len; if (last_byte > 255) { debug("hal_storage: ERROR write request invalid. out of memory!\n"); debug_flush(); return 0; } // write data for (i = 0; i < len; i++) { if (!hal_storage_i2c_write_byte(address + i, buffer[i])) { return 0; } } return 1; }
void ldap_debug_flush(void) { ldap_debug_lock(); if (debug_autoflush & AUTOFLUSH_STUFFED) debug_flush(); ldap_debug_unlock(); }
void debug_printf (debug_level_t level, int prefix, int ln, const char *format, ...) { va_list ap; char buffer[BUFFER_SIZE]; int len; if (level < debug_get_level ()) return; if (prefix) { debug_write_str (debug_prefix[level]); } va_start (ap, format); len = vsprintf (buffer, format, ap); va_end (ap); debug_write_n_str (buffer, len); if (ln) { debug_write_str (NEWLINE); } debug_flush (); }
void ldap_debug_perror( LDAP *ld, LDAP_CONST char *str ) { assert( ld != NULL ); assert( LDAP_VALID( ld ) ); assert( str != NULL ); ldap_debug_lock(); ldap_debug_print( "%s: %s (%d)\n", str ? str : "ldap_debug_perror", ldap_err2string( ld->ld_errno ), ld->ld_errno ); if ( ld->ld_matched != NULL && ld->ld_matched[0] != '\0' ) { ldap_debug_print( "\tmatched DN: %s\n", ld->ld_matched ); } if ( ld->ld_error != NULL && ld->ld_error[0] != '\0' ) { ldap_debug_print( "\tadditional info: %s\n", ld->ld_error ); } if ( ld->ld_referrals != NULL && ld->ld_referrals[0] != NULL) { int i; ldap_debug_print( "\treferrals:\n" ); for (i = 0; ld->ld_referrals[i]; i++) { ldap_debug_print( "\t\t%s\n", ld->ld_referrals[i] ); } } debug_flush(); ldap_debug_unlock(); }
void debug_uart_test(void){ debug("uart: running test\n"); debug_flush(); while(1){ debug("TEST12345\n"); delay_ms(500); } }
void uart_init(void){ debug("uart: init\n"); debug_flush(); uart_rx_callback = 0; hal_uart_init(); }
inline void trig(void) { debug_log("Debug trigger reached at :"); debug_log(this->x); debug_log(this->y); debug_flush(); };
void hal_storage_read(uint8_t *storage_ptr, uint16_t len) { // verify read size if (!hal_storage_check_len(len)) return; if (!hal_storage_i2c_read_buffer(0, storage_ptr, (uint8_t)len)) { debug("hal_storage: ERROR! failed to read buffer\n"); debug_flush(); } }
void debug_init(void) { debug_uart_init(); debug_init_done = 1; debug_put_newline(); debug("### OpenSky - "); debug(DEFINE_TO_STR(BUILD_TARGET)); debug(" - (c) by github.com/fishpepper ###\n"); debug_flush(); debug("uart: init done\n"); }
void ldap_debug_set_autoflush(int enable) { ldap_debug_lock(); enable = enable ? AUTOFLUSH_ENABLED : 0; if ((debug_autoflush ^ enable) & AUTOFLUSH_ENABLED) { if (debug_autoflush == AUTOFLUSH_STUFFED) debug_flush(); debug_autoflush ^= AUTOFLUSH_ENABLED; } ldap_debug_unlock(); }
void printf(const char *fmt, ...) { ASSERT32FLAT(); va_list args; va_start(args, fmt); bvprintf(&screeninfo, fmt, args); va_end(args); if (ScreenAndDebug) debug_flush(); }
static uint32_t hal_storage_check_len(uint16_t len) { if (len > 255) { debug("hal_storage: ERROR, invalid data len "); debug_put_uint16(len); debug(" (max is 255)!\n"); debug_flush(); // invalid return 0; } else { // safe return 1; } }
static void debug_console_write(struct console *co, const char *s, unsigned int count) { unsigned long irq_flags; local_irq_save(irq_flags); while (count--) { if (*s == '\n') debug_putc('\r'); debug_putc(*s++); } debug_flush(); local_irq_restore(irq_flags); }
void ldap_debug_unlock(void) { if (debug_lockdeep > 0) { debug_lockdeep -= 1; if (debug_lockdeep == 0 && debug_autoflush >= (AUTOFLUSH_ENABLED | AUTOFLUSH_STUFFED) && debug_lastc == '\n') debug_flush(); } #ifdef HAVE_PTHREAD_MUTEX_RECURSIVE LDAP_ENSURE(pthread_mutex_unlock(&debug_mutex) == 0); #else LDAP_ENSURE(ldap_pvt_thread_mutex_recursive_unlock(&debug_mutex) == 0); #endif /* HAVE_PTHREAD_MUTEX_RECURSIVE */ }
static void debug_console_write(struct console *co, const char *s, unsigned int count) { unsigned long irq_flags; /* disable irq's while TXing outside of FIQ context */ local_irq_save(irq_flags); while (count--) { if (*s == '\n') debug_putc('\r'); debug_putc(*s++); } debug_flush(); local_irq_restore(irq_flags); }
void panic(const char *fmt, ...) { if (CONFIG_DEBUG_LEVEL) { va_list args; va_start(args, fmt); bvprintf(&debuginfo, fmt, args); va_end(args); debug_flush(); } // XXX - use PANIC PORT. irq_disable(); for (;;) hlt(); }
/* Safe outside fiq context */ static int debug_printf_nfiq(void *cookie, const char *fmt, ...) { char buf[256]; va_list ap; unsigned long irq_flags; va_start(ap, fmt); vsnprintf(buf, 128, fmt, ap); va_end(ap); local_irq_save(irq_flags); debug_puts(buf); debug_flush(); local_irq_restore(irq_flags); return debug_abort; }
void __panic(const char *fname, const char *format, ...) { va_list params; force_interrupts_off(); stack_trace(); printf("\n\n:: EVIL :: %s() :: ", fname); va_start(params, format); __vprintf(format, params); va_end(params); debug_flush(); lock_vmm(); }
void hal_storage_write(uint8_t *buffer, uint16_t len) { // verify write size if (!hal_storage_check_len(len)) return; // disable write protection hal_storage_wp_disable(); delay_ms(1); // execute write if (!hal_storage_i2c_write_buffer(0, buffer, (uint8_t)len)) { debug("hal_storage: ERROR! failed to write buffer\n"); debug_flush(); } // re-enable write protection delay_ms(1); hal_storage_wp_enable(); }
static void dump_result(nameinfo_t *result) { printf("CMD=%s\n", command_to_name(result->cmd)); printf("DRIVE=%c\n", result->drive == NAMEINFO_UNUSED_DRIVE ? '-' : (result->drive == NAMEINFO_UNDEF_DRIVE ? '*' : (result->drive == NAMEINFO_LAST_DRIVE ? 'L' : result->drive + 0x30))); printf("DRIVENAME='%s'\n", result->drivename ? (char*) result->drivename : nullstring); printf("NAME='%s' (%d)\n", result->name ? (char*)result->name : nullstring, result->namelen); printf("ACCESS=%c\n", result->access ? result->access : '-'); printf("TYPE=%c", result->type ? result->type : '-'); debug_putcrlf(); printf("DRIVE2=%c\n", result->file[0].drive == NAMEINFO_UNUSED_DRIVE ? '-' : (result->file[0].drive == NAMEINFO_UNDEF_DRIVE ? '*' : (result->file[0].drive == NAMEINFO_LAST_DRIVE ? 'L' : result->file[0].drive + 0x30))); printf("DRIVENAME2='%s'\n", result->file[0].drivename ? (char*) result->file[0].drivename : nullstring); printf("NAME2='%s' (%d)\n", result->file[0].name ? (char*)result->file[0].name : nullstring, result->file[0].namelen); printf("RECLEN=%d\n", result->recordlen); debug_flush(); }
void prefork_hook (const char *args) { client_state &cs = get_client_state (); if (debug_threads) { debug_printf ("args: %s\n", args); debug_flush (); } #ifdef SIGTTOU signal (SIGTTOU, SIG_DFL); signal (SIGTTIN, SIG_DFL); #endif /* Clear this so the backend doesn't get confused, thinking CONT_THREAD died, and it needs to resume all threads. */ cs.cont_thread = null_ptid; }
void sound_init(void) { debug("sound: init\n"); debug_flush(); sound_init_rcc(); sound_init_gpio(); sound_queue_state = 0; sound_set_frequency(0); /* sound_queue[0].frequency = 500; sound_queue[0].duration_ms = 8000; sound_queue[1].frequency = 890; sound_queue[1].duration_ms = 80; sound_queue[2].frequency = 1000; sound_queue[2].duration_ms = 8000; sound_queue[3].frequency = 0; sound_queue[3].duration_ms = 0; sound_queue_state = 1; */ sound_tone_duration = 0; }
static void debug_fiq(void *data, void *regs) { int c; static int last_c; while ((c = debug_getc()) != -1) { if (!debug_enable) { if ((c == 13) || (c == 10)) { debug_enable = true; debug_count = 0; debug_prompt(); } } else if ((c >= ' ') && (c < 127)) { if (debug_count < (DEBUG_MAX - 1)) { debug_buf[debug_count++] = c; debug_putc(c); } } else if ((c == 8) || (c == 127)) { if (debug_count > 0) { debug_count--; debug_putc(8); debug_putc(' '); debug_putc(8); } } else if ((c == 13) || (c == 10)) { if (c == '\r' || (c == '\n' && last_c != '\r')) { debug_putc('\r'); debug_putc('\n'); } if (debug_count) { debug_buf[debug_count] = 0; debug_count = 0; debug_exec(debug_buf, regs); } else { debug_prompt(); } } last_c = c; } debug_flush(); }
static uint8_t _file_open_callback(int8_t channelno, int8_t errnum, packet_t *rxpacket) { debug_puts("file_open_callback\n"); debug_flush(); // callback to opener // free data structure for next open for (uint8_t i = 0; i < MAX_ACTIVE_OPEN; i++) { if (active[i].channel_no == channelno) { if (errnum < 0) { // we did not receive the packet! active[i].callback(CBM_ERROR_DRIVE_NOT_READY, NULL); } else { // we did receive the reply packet // NOTE: rxdata[0] is actually rxdata[FSP_DATA], as first // byte of reply packet is the error number // Note that the reply packet already sends an official errors.h // error code, so no translation needed uint8_t err = active[i].rxdata[0]; if (err == CBM_ERROR_OPEN_REL) { // when a REL file is opened, we need to proxy the // communication through the bufcmd layer // recordlen uint16_t reclen = (active[i].rxdata[1] & 255) | (active[i].rxdata[2] << 8); // note: automatically closes the original file (on the server) // on error (i.e. err != CBM_ERROR_OK) err = relfile_proxy(channelno, active[i].endpoint, reclen); } active[i].callback(err, (uint8_t *) active[i].rxdata); } active[i].channel_no = -1; break; } } return 0; }
void __dprintf(const char *fmt, ...) { if (!MODESEGMENT && CONFIG_THREADS && CONFIG_DEBUG_LEVEL >= DEBUG_thread && *fmt != '\\' && *fmt != '/') { struct thread_info *cur = getCurThread(); if (cur != &MainThread) { // Show "thread id" for this debug message. debug_putc(&debuginfo, '|'); puthex(&debuginfo, (u32)cur, 8); debug_putc(&debuginfo, '|'); debug_putc(&debuginfo, ' '); } } va_list args; va_start(args, fmt); bvprintf(&debuginfo, fmt, args); va_end(args); debug_flush(); }
void io_init(void) { debug("io: init\n"); debug_flush(); hal_io_init(); }
// opens the file, registers an error code in command->error if necessary // If the open was successful, setup a channel for the given channel number // (note: explicitely not secondary device number, as IEEE and IEC in parallel // use overlapping numbers, so they may be shifted or similar to avoid clashes) // // The command buffer is used as transmit buffer, so it must not be overwritten // until the open has been sent. // // note that if it returns a value <0 on error, it has to have the error message // set appropriately. // int8_t file_open(uint8_t channel_no, bus_t *bus, errormsg_t *errormsg, void (*callback)(int8_t errnum, uint8_t *rxdata), uint8_t openflag) { assert_not_null(bus, "file_open: bus is null"); cmd_t *command = &(bus->command); rtconfig_t *rtconf = &(bus->rtconf); #ifdef DEBUG_FILE debug_printf("OPEN FILE: FOR CHAN: %d WITH NAME: '%s', OPENFLAG=%d\n", channel_no, (char*)&(command->command_buffer), openflag); #endif // note: in a preemtive env, the following would have to be protected // to be atomic as we modify static variables parse_filename(command, &nameinfo, (openflag & OPENFLAG_LOAD) ? PARSEHINT_LOAD : 0); #ifdef DEBUG_FILE debug_printf(" PARSE -> ACCESS=%c, TYPE=%c\n", nameinfo.access, nameinfo.type); #endif // drive handling needed for error message drive if (nameinfo.drive == NAMEINFO_LAST_DRIVE) { nameinfo.drive = rtconf->last_used_drive; } else if (nameinfo.drive == NAMEINFO_UNUSED_DRIVE) { // TODO: match CBM behavior nameinfo.drive = rtconf->last_used_drive; } int8_t errdrive = rtconf->errmsg_with_drive ? nameinfo.drive : -1; // post-parse if (nameinfo.cmd != CMD_NONE && nameinfo.cmd != CMD_DIR && nameinfo.cmd != CMD_OVERWRITE) { // command name during open // this is in fact ignored by CBM DOS as checked with VICE's true drive emulation debug_printf("NO CORRECT CMD: %s\n", command_to_name(nameinfo.cmd)); nameinfo.cmd = 0; } if (nameinfo.type != 0 && nameinfo.type != 'S' && nameinfo.type != 'P' && nameinfo.type != 'U' && nameinfo.type != 'L') { // not set, or set as not sequential and not program debug_puts("UNKOWN FILE TYPE: "); debug_putc(nameinfo.type); debug_putcrlf(); set_error_tsd(errormsg, CBM_ERROR_FILE_TYPE_MISMATCH, 0, 0, errdrive); return -1; } if (nameinfo.access != 0 && nameinfo.access != 'W' && nameinfo.access != 'R' && nameinfo.access != 'A' && nameinfo.access != 'X') { debug_puts("UNKNOWN FILE ACCESS TYPE "); debug_putc(nameinfo.access); debug_putcrlf(); // not set, or set as not read, write, or append, or r/w ('X') set_error_tsd(errormsg, CBM_ERROR_SYNTAX_UNKNOWN, 0, 0, errdrive); return -1; } if (nameinfo.cmd == CMD_DIR && (nameinfo.access != 0 && nameinfo.access != 'R')) { // trying to write to a directory debug_puts("WRITE TO DIRECTORY!"); debug_putcrlf(); set_error_tsd(errormsg, CBM_ERROR_FILE_EXISTS, 0, 0, errdrive); return -1; } uint8_t type = FS_OPEN_RD; // file access default if (nameinfo.access == 0) { if (openflag == OPENFLAG_LOAD) { nameinfo.access = 'R'; } else if (openflag == OPENFLAG_SAVE) { nameinfo.access = 'W'; } } // file type defaults if (nameinfo.type == 0) { // do we create a file (access=='W')? if (nameinfo.access == 'W') { // write (like save) if (openflag == OPENFLAG_SAVE) { nameinfo.type = 'P'; } else { nameinfo.type = 'S'; } } if (nameinfo.access == 'R') { if (openflag == OPENFLAG_LOAD) { // on load, 'P' is the default nameinfo.type = 'P'; } } } if (nameinfo.access == 'X') { // trying to open up a R/W channel debug_puts("OPENING UP A R/W CHANNEL!"); debug_putcrlf(); type = FS_OPEN_RW; } if (nameinfo.name[0] == '#') { // trying to open up a direct channel // Note: needs to be supported for D64 support with U1/U2/... // Note: '#' is still blocking on read! debug_puts("OPENING UP A DIRECT CHANNEL!"); debug_putcrlf(); type = FS_OPEN_DIRECT; } // if ",W" or secondary address is one, i.e. save if (nameinfo.access == 'W') { type = FS_OPEN_WR; } if (nameinfo.access == 'A') { type = FS_OPEN_AP; } if (nameinfo.cmd == CMD_DIR) { if (openflag & OPENFLAG_LOAD) { type = FS_OPEN_DR; } else { type = FS_OPEN_RD; } } else if (nameinfo.cmd == CMD_OVERWRITE) { type = FS_OPEN_OW; } #ifdef DEBUG_FILE debug_printf("NAME='%s' (%d)\n", nameinfo.name, nameinfo.namelen); debug_printf("ACCESS=%c\n", nameinfo.access); debug_printf("CMD=%d\n", nameinfo.cmd); debug_flush(); #endif return file_submit_call(channel_no, type, command->command_buffer, errormsg, rtconf, callback, 0); }
void main(void) { BRD_init(); //Initalise NP2 Hardware_init(); HAL_Delay(3000); struct PanTilt pantiltvars; pantilt = &pantiltvars; pantilt->write_angles = 0; pantilt->read_angles = 0; pantilt->set_angle_pan = 0; pantilt->set_angle_tilt = 0; struct Variables variables; vars = &variables; vars->count = 0; vars->bit_half = 1; vars->bit_count = 0; vars->encoded_bit_count = -1; vars->encoded_bit = 0; vars->encoded_char = hamming_byte_encoder('<'); vars->transmit_frequency = 1000; vars->period_multiplyer = ((1.000000/vars->transmit_frequency)*500)*0.998; vars->recieve_element = 0; vars->recieve_flag = 0; Pb_init(); s4353096_radio_setchan(s4353096_chan); s4353096_radio_settxaddress(s4353096_tx_addr); s4353096_radio_setrxaddress(s4353096_rx_addr); while (1) { s4353096_radio_setfsmrx(); s4353096_radio_fsmprocessing(); if (vars->recieve_flag == 1) { manchester_decode(); vars->recieve_flag = 0; } if (mode == S4353096_RADIO) { /*Processes the current fsm state*/ RxChar = debug_getc(); if (RxChar != '\0') { s4353096_keystroke = 1; while(s4353096_keystroke == 1){ if (RxChar == '\r' || s4353096_payload_length == 7) { for (int j = s4353096_payload_length; j < 7; j++) { s4353096_payload_buffer[j] = '-'; } s4353096_radio_fsmcurrentstate = S4353096_IDLE_STATE; s4353096_radio_fsmprocessing(); s4353096_radio_fsmcurrentstate = S4353096_TX_STATE; debug_printf("\n"); /*Compiles the transmit packet. Transmits packet if in TX state*/ s4353096_radio_sendpacket(s4353096_radio_getchan(), s4353096_addr_get, s4353096_payload_buffer); s4353096_radio_fsmprocessing(); s4353096_radio_setfsmrx(); s4353096_radio_fsmprocessing(); s4353096_payload_length = 0; s4353096_keystroke = 0; } else if (RxChar != '\0') { s4353096_payload_buffer[s4353096_payload_length] = RxChar; s4353096_payload_length++; debug_putc(RxChar); //reflect byte using putc - puts character into buffer debug_flush(); //Must call flush, to send character //reflect byte using printf - must delay before calling printf again. } else { } HAL_Delay(125); RxChar = debug_getc(); } } else { } s4353096_radio_fsmprocessing(); if (s4353096_radio_getrxstatus() == 1) { //Checks if packet has been recieved /*Prints recieved packet to console*/ s4353096_radio_getpacket(s4353096_rx_buffer); } else { } } if (pantilt->write_angles == 1) { s4353096_pantilt_angle_write(1, pantilt->set_angle_pan); s4353096_pantilt_angle_write(0, pantilt->set_angle_tilt); pantilt->write_angles = 0; } if (((HAL_GetTick()/10000) % 100) == 0) { debug_printf("\nPan: %d Tlit: %d\n", pantilt->set_angle_pan, pantilt->set_angle_tilt); } if (pantilt->read_angles == 1) { /*Delay for 1 second or setup to delay for 0.2 seconds and set angle to += or -= 1 each time*/ if (mode == S4353096_JOYSTICK) { y_value = s4353096_joystick_y_read(); if ((y_value > 2500) && (pantilt->set_angle_pan < 76)) { pantilt->set_angle_pan += 1; } else if ((y_value < 1550) && (pantilt->set_angle_pan > -76)) { pantilt->set_angle_pan -= 1; } else { //Joystick is stationary, no input } x_value = s4353096_joystick_x_read(); if ((x_value > 2500) && (pantilt->set_angle_tilt < 76)) { pantilt->set_angle_tilt += 1; } else if ((x_value < 1550) && (pantilt->set_angle_tilt > -76)) { pantilt->set_angle_tilt -= 1; } else { } } else if (mode == S4353096_TERMINAL) { /* Receive characters using getc */ RxChar = debug_getc(); /* Check if character is not Null */ if (RxChar != '\0') { switch (RxChar) { case 'w': pantilt->set_angle_tilt += 1; break; case 's': pantilt->set_angle_tilt -= 1; break; case 'a': pantilt->set_angle_pan += 1; break; case 'd': pantilt->set_angle_pan -= 1; break; case 't': mode = S4353096_LASER_TRANSMIT; break; default: break; } debug_flush(); } s4353096_terminal_angle_check(); } pantilt->read_angles = 0; } } }