mbgtools-lx
4.2.8
|
Functions | |
_MBG_API_ATTR MBG_DEV_HANDLE _MBG_API | mbg_open_device (int dev_idx) |
Open a device by index number. More... | |
_MBG_API_ATTR MBG_DEV_HANDLE _MBG_API | mbg_open_device_by_dev_fn (const char *dev_fn) |
Open a device specified by a device file name. More... | |
_MBG_API_ATTR MBG_DEV_HANDLE _MBG_API | mbg_open_device_by_hw_id (const char *dev_fn) |
Open a device specified by a device file name. More... | |
_MBG_API_ATTR MBG_DEV_HANDLE _MBG_API | mbg_open_device_by_name (const MBG_DEV_NAME srch_name, int selection_mode) |
Return a handle to a device with a particular device name. More... | |
Each of these functions can be used to open a device to obtain a valid MBG_DEV_HANDLE handle which can be used with subsequent API calls to access the particular device.
If the device fails to be opened then each of these functions returns MBG_INVALID_DEV_HANDLE, and an OS-specific "last error" code is set accordingly. The caller can then use mbg_get_last_error immediately to retrieve the OS-specific error code, convert it, and return the associated Meinberg-specific error code. See MBG_ERROR_CODES.
Operating systems maintain a list of devices that are currently present in a system. The function mbg_open_device expects a number that is used as an index to this list. If only a single supported device is present then index 0 can always be used to open that device.
The function mbg_find_devices can be used to retrieve the number of devices statically present in the system, and the highest index number that can be used is the number of devices - 1.
In a plug-and-play system the device list maintained by the operating system may change over time, for example if a USB device is plugged in or out during operation. In this case index numbers may change, and may not always refer to the same device.
So the function mbg_open_device_by_name can be used instead to open a specific device identified by model name and optionally serial number. See MBG_DEV_NAME for the format of such device name.
If a list of unique device names is required e.g. to set up a device selection dialog in a GUI application then the function mbg_find_devices_with_names can be used to allocate and set up such a list. When the list has been evaluated and isn't needed anymore then mbg_free_device_name_list should be called to free the allocated memory.
Inside the operating system the device is always identified by a device file name which can be used internally with an OS-specific "open" function, e.g. "open" on POSIX systems, or ""CreateFile" on Windows.
While the device file name is a complex string under Windows, under Linux and similar systems this is just a device node name like "/dev/mbgclock0" which can easily be used to specify a particular device. See MBG_DEV_FN.
On such systems the function mbg_open_device_by_dev_fn can be used to open a device specified by a device file name.
MBG_DEV_HANDLE mbg_open_device | ( | int | dev_idx | ) |
Open a device by index number.
If the call fails then mbg_get_last_error should be called immediately to get the reason why.
For details and similar functions see API functions that can be used to open a device.
[in] | dev_idx | Device index number, starting from 0. |
Definition at line 3352 of file mbgdevio.c.
References mbg_dev_fn_from_dev_idx(), MBG_INVALID_DEV_HANDLE, mbg_open_device_by_dev_fn(), n_ddevs, and pcps_ddev.
Referenced by do_mbgsvctasks(), mbg_find_devices(), mbg_open_device_by_name(), and mbg_open_device_by_param().
MBG_DEV_HANDLE mbg_open_device_by_dev_fn | ( | const char * | dev_fn | ) |
Open a device specified by a device file name.
The format the device file name depends on the operating system. see MBG_DEV_FN.
If the call fails then mbg_get_last_error should be called immediately to get the reason why.
For details and similar functions see API functions that can be used to open a device.
[in] | dev_fn | The device file name |
Definition at line 3410 of file mbgdevio.c.
References MBG_INVALID_DEV_HANDLE.
Referenced by get_dev_info_for_dev_fn(), mbg_open_device(), mbg_open_device_by_hw_id(), mbg_open_device_by_name(), mbg_open_device_by_param(), and setup_dev_fn_list().
MBG_DEV_HANDLE mbg_open_device_by_hw_id | ( | const char * | dev_fn | ) |
Open a device specified by a device file name.
The format the device file name depends on the operating system. see MBG_DEV_FN.
If the call fails then mbg_get_last_error should be called immediately to get the reason why.
For details and similar functions see API functions that can be used to open a device.
[in] | dev_fn | The device file name, see MBG_DEV_FN |
The format the device file name depends on the operating system. see MBG_DEV_FN.
If the call fails then mbg_get_last_error should be called immediately to get the reason why.
For details and similar functions see API functions that can be used to open a device.
[in] | dev_fn | The device file name, see MBG_DEV_FN |
Definition at line 3482 of file mbgdevio.c.
References mbg_open_device_by_dev_fn().
MBG_DEV_HANDLE mbg_open_device_by_name | ( | const MBG_DEV_NAME | srch_name, |
int | selection_mode | ||
) |
Return a handle to a device with a particular device name.
See MBG_DEV_NAME for the possible formats of a device name.
If the call fails then mbg_get_last_error should be called immediately to get the reason why.
For details and similar functions see API functions that can be used to open a device.
[in] | srch_name | String with the MBG_DEV_NAME of a device to be opened |
[in] | selection_mode | One of the MBG_MATCH_MODES |
Definition at line 4112 of file mbgdevio.c.
References _int_from_size_t, _MBG_DEV_FN_LIST_ENTRY::dev_fn_ptr, free_dev_fn_list(), get_dev_info_for_dev_fn(), lookup_dev_idx_ex(), mbg_find_devices(), MBG_INVALID_DEV_HANDLE, mbg_open_device(), mbg_open_device_by_dev_fn(), mbg_rc_is_success, mbg_split_dev_name(), n_ddevs, N_SUPP_DEV_BUS, _MBG_DEV_FN_LIST_ENTRY::next, pcps_ddev, setup_dev_fn_list(), and sn_cpy_str_safe().
Referenced by mbg_open_device_by_param().