Implementing an additional, high-priority thread for monitoring serial data - page 2 - General Discussion and Assistance - CHDK Forum

Implementing an additional, high-priority thread for monitoring serial data

  • 42 Replies
  • 20579 Views
Re: Implementing an additional, high-priority thread for monitoring serial data
« Reply #10 on: 04 / December / 2007, 05:10:16 »
Advertisements
Currently the code is receive only - I read on dpreview that someone has found how to manipulate the TX bit, which could allow for serial output from the camera. I haven't looked at this in any detail yet, but it seems feasible at least.

Re: Implementing an additional, high-priority thread for monitoring serial data
« Reply #11 on: 04 / December / 2007, 05:22:51 »
This is very interesting! I found a difference in the reading the USB signal. In s3 the reading take place after _kbd_read_keys_r2 routine in others before this routine. That could explain why I get this big delay. I will check tonight. Very promising, nice work!

Re: Implementing an additional, high-priority thread for monitoring serial data
« Reply #12 on: 04 / December / 2007, 08:28:18 »
Success! I can now talk to my A640 (one byte at a time) at 4800 baud (faster speeds should be perfectly possible) with moderate reliability ... With a little bit of work this makes an awful lot of applications feasible.  8)

... including multi-camera shooting!  :)

Re: Implementing an additional, high-priority thread for monitoring serial data
« Reply #13 on: 04 / December / 2007, 09:30:45 »
> When my_kbd_read_keys() is called, enter a loop that continuously checks the USB power level.


I thought that function was only called every 10 msec ?


Do you know if any routines call 'gui_kbd_process' , I cannot find any ?



David


Re: Implementing an additional, high-priority thread for monitoring serial data
« Reply #14 on: 04 / December / 2007, 09:55:18 »
It's only called every 10ms, but you can tie it up for longer. (I've just realised I must be tying it up for 10ms as I'm using a timeout based around get_tick_count, which only seems to have a 10ms resolution).

Quote
Do you know if any routines call 'gui_kbd_process' , I cannot find any ?

gui_kbd_process is called core/kbd.c, under kbd_process:

Code: [Select]
if (kbd_is_key_pressed(KEY_SHOOT_FULL)){
    key_pressed = 100;
    if (!state_kbd_script_run){
                script_console_clear();
                script_console_add_line(lang_str(LANG_CONSOLE_TEXT_STARTED));
script_start();
    } else {
                script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED));
script_end();
    }
}

if (state_kbd_script_run)
    process_script();
else {
    gui_kbd_process();
}


Try this useful and fast utility; it searches through text files for a string and shows you the number of matches:
Simple Search/Replace

Re: Implementing an additional, high-priority thread for monitoring serial data
« Reply #15 on: 04 / December / 2007, 10:33:11 »
Thanks.
I do not know why I could not find that.

If you are taking-up so much of the 10msec time-slot, does CHDK have time to do anything else ?



David

Re: Implementing an additional, high-priority thread for monitoring serial data
« Reply #16 on: 04 / December / 2007, 10:49:35 »
Logically it shouldn't have a chance to do much anything, but it doesn't seem unresponsive so far. Very peculiar. I'm going to remove the dependency on get_tick_count and just loop around it a certain number of times for a timeout instead.

Re: Implementing an additional, high-priority thread for monitoring serial data
« Reply #17 on: 04 / December / 2007, 12:11:18 »
I'm very disappointed now. I cannot get rid of the 50 ms delay on the s3?! Questions: On A640 is it possible to use the canon remote capture software to remote control the camera from the PC (over USB)? Also does the camera enter download mode when you connect the USB cable (enter play mode and waiting for PC connection)?


Re: Implementing an additional, high-priority thread for monitoring serial data
« Reply #18 on: 04 / December / 2007, 13:17:55 »
Yes, it's possible to use the remote capture app (but I've never tried).

With the camera on playback mode, it does connect to the PC when you plug in the USB. My camera crashes shortly after when running my compiled firmware (probably due to the cycles taken up by my routine!)

Re: Implementing an additional, high-priority thread for monitoring serial data
« Reply #19 on: 04 / December / 2007, 14:35:29 »
Thanks for the info. I thought maybe that was different from s3, and could explain my 50ms ;)

 

Related Topics