Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No key press detected for pending in [iperf server] example #473

Closed
crispsssy opened this issue Feb 24, 2024 · 1 comment
Closed

No key press detected for pending in [iperf server] example #473

crispsssy opened this issue Feb 24, 2024 · 1 comment

Comments

@crispsssy
Copy link

Hi,

I tried to run pico w iperf server example, in the example there are some pending functions say "press 'd' to disconnect", but when I press keys on keyboard, only PICO_ERROR_TIMEOUT is returned by getchar_timeout_us(0).

Here is an simple code I copied from iperf example:

char key = '!';

void key_pressed_worker_func(async_context_t* context, async_when_pending_worker_t* worker){
        printf("%d is pressed\n", key);
        cyw43_arch_disable_sta_mode();
}

static async_when_pending_worker_t key_pressed_worker = {
        .do_work = key_pressed_worker_func
};

void key_pressed_func(void* param){
        key = getchar_timeout_us(0);
        printf("key is pressed");
//        if(key == 'd' || key == 'D'){
                async_context_set_work_pending((async_context_t*)param, &key_pressed_worker);
//        }
}

int main(){
        stdio_init_all();
        if(cyw43_arch_init()){
                printf("failed to initialise\n");
                return 1;
        }

        async_context_add_when_pending_worker(cyw43_arch_async_context(), &key_pressed_worker);
        stdio_set_chars_available_callback(key_pressed_func, cyw43_arch_async_context());
//something else after this line

The printf() in key_pressed_func() is never been called and the printf() in key_press_worker_func() gives "-1 is pressed" (-1 means timeout from getchar_timeout_us(0)).
here is the output from minimum:

Welcome to minicom 2.9

OPTIONS: 
Compiled on Feb  7 2024, 07:41:55.
Port /dev/tty.usbmodem21201, 21:19:35

Press Meta-Z for help on special keys

-1 is pressed
-1 is pressed
-1 is pressed
-1 is pressed
-1 is pressed
-1 is pressed
-1 is pressed

what is wrong?

@peterharperuk
Copy link
Contributor

Duplicate #474

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants