Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    How to check if device is USB/PC mode?

    Reply
    jaeezzy | # 1 | 2010-01-16, 09:18 | Report

    Hi,
    I was wondering if anyone can help me as to how I can check if the device is in usb or pc suite mode. I checked libosso but couldn't get any clue and also checked the mce-dev but couldn't see usb/pc modes anywhere. Also I tried going through dbus api but couldn't figure out where to look. So, I would be very grateful for any hints/help coz I'm completely noob when it comes to these api. Thanks

    Edit | Forward | Quote | Quick Reply | Thanks

     
    BlueGene | # 2 | 2010-01-16, 12:36 | Report

    gconftool-2 is your friend ;-)

    Output USB disconnected:

    Code:
    Nokia-N900-51-1:~# gconftool-2 -R / | grep usb
       sync-usb-mode = false
           statusbar_icon_name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
           statusbar_dimmed_icon_name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
           statusbar_icon_name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
           statusbar_dimmed_icon_name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
           statusbar_icon_name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
           statusbar_dimmed_icon_name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
         mmc-used-over-usb = Schema (type: `bool' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
         usb-mode = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
         internal-mmc-used-over-usb = Schema (type: `bool' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
         usb-device-name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
         usb-cable-attached = Schema (type: `bool' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
          statusbar_icon_name = general_adhocwlan
          statusbar_dimmed_icon_name = statusarea_internetconnection_no
          statusbar_icon_name = general_packetdata
          statusbar_dimmed_icon_name = statusarea_internetconn_packetdata_dimmed
          statusbar_icon_name = general_wlan
          statusbar_dimmed_icon_name = statusarea_internetconnection_no
        mmc-used-over-usb = false
        usb-mode = idle
        internal-mmc-used-over-usb = false
        usb-device-name = unknown
        usb-cable-attached = false

    Output USB connected with mass-storage-mode:

    Code:
    Nokia-N900-51-1:~# gconftool-2 -R / | grep usb
       sync-usb-mode = false
           statusbar_icon_name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
           statusbar_dimmed_icon_name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
           statusbar_icon_name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
           statusbar_dimmed_icon_name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
           statusbar_icon_name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
           statusbar_dimmed_icon_name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
         mmc-used-over-usb = Schema (type: `bool' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
         usb-mode = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
         internal-mmc-used-over-usb = Schema (type: `bool' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
         usb-device-name = Schema (type: `string' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
         usb-cable-attached = Schema (type: `bool' list_type: '*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
          statusbar_icon_name = general_adhocwlan
          statusbar_dimmed_icon_name = statusarea_internetconnection_no
          statusbar_icon_name = general_packetdata
          statusbar_dimmed_icon_name = statusarea_internetconn_packetdata_dimmed
          statusbar_icon_name = general_wlan
          statusbar_dimmed_icon_name = statusarea_internetconnection_no
        mmc-used-over-usb = false
        usb-mode = peripheral
        internal-mmc-used-over-usb = true
        usb-device-name = USB-Gerät
        usb-cable-attached = true
    Now you only have to find out, where these entries exactly are and how to modify them consistently. But I suppose this wont be difficult anymore ;-)

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to BlueGene For This Useful Post:
    jaeezzy

     
    jaeezzy | # 3 | 2010-01-16, 13:56 | Report

    Originally Posted by BlueGene View Post
    gconftool-2 is your friend ;-)

    Now you only have to find out, where these entries exactly are and how to modify them consistently. But I suppose this wont be difficult anymore ;-)
    Thanks for this BlueGene. How can I use this with my code. Hopefully I can make use of it.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    pH5 | # 4 | 2010-01-18, 07:24 | Report

    Check out http://maemo.org/development/, you can find a link to the GConf Reference Manual right on the front page. There's also a link to the Code samples right there. maemo-examples contains two example GConf programs (one for just setting/reading a GConf key, and one for listening to changes).

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to pH5 For This Useful Post:
    jaeezzy

     
    jaeezzy | # 5 | 2010-01-18, 09:24 | Report

    Thanks for the tips guys. However, I came across lshal and here's my effort so far without any luck so plz help me if I'm not on the right track. I would be very grateful. Thanks.

    Code:
    #include <hal/libhal.h>
    #include <stdio.h>
    #include <string.h>
    
    //void set_up(LibHalContext*);
    void _device_added(LibHalContext*, const char*);
    void _device_removed(LibHalContext*, const char*);
    void _property_modified(LibHalContext*, const char*, const char*, dbus_bool_t, dbus_bool_t);
    
    int main(int argc, char *argv[]){
    	printf("Starting hal\n");
    	LibHalContext *ctx = libhal_ctx_new();
    	DBusConnection *dbus;
    	dbus = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
    	if (dbus == NULL)
    		printf("ERROR CONNECTION DBUS.\n");
    	else
    		printf("Successfully connected to DBus.\n");
    	printf("connecting hal to dbus.\n");
    	libhal_ctx_set_dbus_connection(ctx, dbus);
    	
    	libhal_ctx_set_device_added(ctx, _device_added);
    	libhal_ctx_set_device_removed(ctx, _device_removed);
    	
    	libhal_ctx_init(ctx, NULL);
    	printf("Watching devices...\n");
    	libhal_device_property_watch_all(ctx, NULL);
    	
    	return 0;
    }
    
    void _device_added(LibHalContext *ctx, const char *udi){
    	printf("UDI: %s\n", udi);
    	if (strcmp(udi, "/org/freedesktop/Hal/devices/usb_device_1d6b_2_musb_hdrc") == 0){
    		printf("Usb added.\n");
    	}else
    		printf("Unidentified device added.\n");
    }
    
    void _device_removed(LibHalContext *ctx, const char *udi){
    	printf("UDI: %s\n", udi);
    	if (strcmp(udi, "/org/freedesktop/Hal/devices/usb_device_1d6b_2_musb_hdrc") == 0){
    		printf("Usb removed.\n");
    	}else
    		printf("Unidentified device removed.\n");
    }

    Edit | Forward | Quote | Quick Reply | Thanks

     
vBulletin® Version 3.8.8
Normal Logout