/*----------------------------------------------------------------------------*/ int info_device(ASerialPort_t* aPort, ADeviceNXP_t* aDevice) { int test = nxp_device_info(aPort,aDevice); if(test) printf("[ERROR] Cannot get device info? (%d)\n",test); else show_device(aDevice); return test; }
int main (int argc, char *argv[]) { NMClient *client; GError *error = NULL; const GPtrArray *devices; int i; #if !GLIB_CHECK_VERSION (2, 35, 0) /* Initialize GType system */ g_type_init (); #endif if (!(client = nm_client_new (NULL, &error))) { g_message ("Error: Could not connect to NetworkManager: %s.", error->message); g_error_free (error); return EXIT_FAILURE; } if (!nm_client_get_nm_running (client)) { g_message ("Error: Can't obtain devices: NetworkManager is not running."); return EXIT_FAILURE; } /* Now the devices can be listed. */ devices = nm_client_get_devices (client); printf ("Devices:\n============\n"); for (i = 0; i < devices->len; i++) show_device (devices->pdata[i]); g_object_unref (client); return EXIT_SUCCESS; }
/** * extern struct sysfs_device *sysfs_get_bus_device(struct sysfs_bus *bus, * char *id); * * flag: * 0 : bus -> valid, id -> valid * 1 : bus -> valid, id -> invalid * 2 : bus -> valid, id -> NULL * 3 : bus -> NULL, id -> valid * 4 : bus -> NULL, id -> invalid * 5 : bus -> NULL, id -> NULL */ int test_sysfs_get_bus_device(int flag) { struct sysfs_bus *bus = NULL; struct sysfs_device *dev = NULL; char *bus_name = NULL; char *id = NULL; switch(flag) { case 0: bus_name = val_bus_name; bus = sysfs_open_bus(bus_name); if (bus == NULL) { dbg_print("%s: sysfs_open_bus() failed\n",__FUNCTION__); return 0; } id = val_bus_id; break; case 1: bus_name = val_bus_name; bus = sysfs_open_bus(bus_name); if (bus == NULL) { dbg_print("%s: sysfs_open_bus() failed\n",__FUNCTION__); return 0; } id = inval_name; break; case 2: bus_name = val_bus_name; bus = sysfs_open_bus(bus_name); if (bus == NULL) { dbg_print("%s: sysfs_open_bus() failed\n",__FUNCTION__); return 0; } id = NULL; break; case 3: bus = NULL; id = val_bus_id; break; case 4: bus = NULL; id = inval_name; break; case 5: bus = NULL; id = NULL; break; default: return -1; } dev = sysfs_get_bus_device(bus, id); switch (flag) { case 0: if (dev == NULL) { if (errno == 0) dbg_print("%s: Device %s not on bus %s\n", __FUNCTION__, id, bus_name); else dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); } else { dbg_print("%s: SUCCEEDED with flag = %d\n\n", __FUNCTION__, flag); show_device(dev); dbg_print("\n"); } break; case 1: case 2: case 3: case 4: case 5: if (dev != NULL) dbg_print("%s: FAILED with flag = %d errno = %d\n", __FUNCTION__, flag, errno); else dbg_print("%s: SUCCEEDED with flag = %d\n", __FUNCTION__, flag); break; default: break; } if (bus != NULL) sysfs_close_bus(bus); return 0; }
static void show_uio_info(struct uio_info_t *info) { show_device(info); show_maps(info); if (opt_verbose) show_dev_attrs(info); }