Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6739909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:32:36+00:00 2026-05-26T11:32:36+00:00

Hello I am working on an embedded linux device with a usb port that

  • 0

Hello I am working on an embedded linux device with a usb port that uses the g_ether driver for usb networking.

When the usb plug is connected the dmesg output is:

g_ether gadget: full speed config #2: RNDIS

When the usb cable is unplugged no message is written to dmesg.

Using C how can I listen for the connect/disconnect events?

The embedded linux OS does not have any extras. There is no dbus daemon or hotplug helper script. I am not even sure if these would of been helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:32:37+00:00Added an answer on May 26, 2026 at 11:32 am

    If you want everything in your single process, you’ll have to use libudev to either get events from udevd or directly from the kernel.

    Seeing that it might be a problem to use libudev in your application (lack of documentation?), an alternative is to use the udevadm program, which can:

    • report device events after being processed by udevd (udevadm monitor --udev --property),
    • report devive events directly from the kernel (udevadm monitor --kernel --property), and
    • dump udevd’s database of current devices (but not the kernel’s!) (udevadm info --query all --export-db)

    udevadm is part of the udev package, but shouldn’t need udevd if you only use it to report kernel events. You can use it by having your process spawn it and parse its standard output (but you’ll have to launch it via stdbuf -o L ).

    Either way, it’ll probably be a lot of work. I’ve already implemented a lot of this in my NCD programming language, including monitoring of USB devices. You might want to take a look at NCD; it’s useful for a lot of configuration tasks, and handles hotplugging well. For example, this NCD program will print USB device events to standard output:

    process main {
        sys.watch_usb() watcher;
        println(watcher.event_type, " ", watcher.devname, " ", watcher.vendor_id, ":", watcher.model_id);
        watcher->nextevent();
    }
    

    This will make NCD print something like that (with an initial added event for any USB device that was already plugged in):

    added /dev/bus/usb/002/045 0409:0059
    added /dev/bus/usb/002/046 046d:c313
    added /dev/bus/usb/002/047 046d:c03e
    added /dev/bus/usb/002/048 0557:2008
    removed /dev/bus/usb/002/048 0557:2008
    

    You can also use NCD just for this, and parse this standard output – which is much easier to work with than messing with udevadm directly.

    Note that NCD itself uses udevadm, and it does require udevd to be running; but why is that a problem anyway? (with some work this dependency could be removed)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I am working with a simulator that uses rcS scripts to boot, this
I am working on an embeeded device.and it is connected on COM6 port when
Hello I have this list that i am working on. When i move the
Hello Ruby/Rails/Merb developers! Im currently working on a web project that will have a
Hello: I am working on a C# project that reads an XML file and
Hello stack overflowers, I have a desing that uses the flyweight pattern to share
Hello im working in a generic function that sends an ajax request according with
Hello I am working with an application that already has a few validation criterion,
Hello i m Working On Application That Requires Northwest and Southeast Coordinates of Mapview
I am working on a PHP app that requires eight javascript files (hello web2.0).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.