Skip to content

Commit

Permalink
Merge pull request #9 from polarikus/0.98.1api-fix
Browse files Browse the repository at this point in the history
0.98.1 api support
  • Loading branch information
polarikus authored Jan 30, 2024
2 parents 5baa4d5 + 9f5d4fe commit 2eab1cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ App(
fap_libs=["assets"],
fap_description="Emulates a barcode scanner for testing cash registers. Why buy a scanner when you have a flipper?",
fap_author="Igor Danilov",
fap_version=(0, 2),
fap_version=(0, 3),
order=70,
fap_category="USB",
fap_icon_assets="icons"
Expand Down
18 changes: 11 additions & 7 deletions bc_scanner_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct BarCodeScript {
uint8_t file_buf[FILE_BUFFER_LEN];
uint8_t buf_len;
bool is_file_end;
FuriHalSerialHandle* serial_handle;
};

/**
Expand All @@ -57,26 +58,29 @@ static void scan_sound() {
/**
*
*/
static void usb_uart_serial_init() {
static void usb_uart_serial_init(BarCodeScript* bc_script) {
furi_hal_usb_unlock();
Cli* cli = furi_record_open(RECORD_CLI);
cli_session_close(cli);
furi_record_close(RECORD_CLI);
furi_check(furi_hal_usb_set_config(&usb_cdc_single, NULL) == true);
furi_hal_console_disable();
furi_hal_uart_set_br(FuriHalUartIdUSART1, UART_BAUD);

bc_script->serial_handle = furi_hal_serial_control_acquire(FuriHalSerialIdUsart);

furi_hal_serial_init(bc_script->serial_handle, UART_BAUD);
}

/**
*
*/
static void usb_uart_serial_deinit() {
static void usb_uart_serial_deinit(BarCodeScript* bc_script) {
furi_hal_usb_unlock();
furi_check(furi_hal_usb_set_config(&usb_cdc_single, NULL) == true);
Cli* cli = furi_record_open(RECORD_CLI);
cli_session_open(cli, &cli_vcp);
furi_record_close(RECORD_CLI);
furi_hal_console_enable();
furi_hal_serial_deinit(bc_script->serial_handle);
furi_hal_serial_control_release(bc_script->serial_handle);
}
/**
*
Expand Down Expand Up @@ -121,7 +125,7 @@ static int32_t bc_scanner_worker(void* context) {
//uint8_t buff[5] = {'p', 'r', 'i', 'v', 'k'};
//uint8_t state = 99;

usb_uart_serial_init();
usb_uart_serial_init(bc_script);

while(1) {
//state = furi_hal_cdc_get_ctrl_line_state(FuriHalUartIdUSART1);
Expand Down Expand Up @@ -192,7 +196,7 @@ static int32_t bc_scanner_worker(void* context) {
}
}

usb_uart_serial_deinit();
usb_uart_serial_deinit(bc_script);
storage_file_close(script_file);
storage_file_free(script_file);
FURI_LOG_I(WORKER_TAG, "End");
Expand Down

0 comments on commit 2eab1cb

Please sign in to comment.