Core
The HDF implements driver framework capabilities such as driver loading, service management, and driver message model. You can develop drivers based on the HDF.
Since:
1.0
Summary
Files
Data Structures
Defines the power management functions provided by the HDF for the driver. |
|
Defines a HdfSBuf. |
Macros
Typedefs
OnEventReceived) (void priv, uint32_t id, struct data) |
Enumerations
ServicePolicy { = 0, SERVICE_POLICY_PUBLIC, , SERVICE_POLICY_FRIENDLY, , SERVICE_POLICY_INVALID } |
Enumerates policies for releasing driver services developed based on the HDF. |
{ DEVICE_PRELOAD_ENABLE = 0, , DEVICE_PRELOAD_INVALID } |
Functions
const struct HdfObject Obtains the driver service object based on a driver service name. |
|
(const struct HdfDeviceObject deviceObject) |
|
(struct HdfDeviceObject deviceObject, const char serviceName, struct callback) |
|
HdfDeviceSendEvent (const struct deviceObject, uint32_t id, const struct HdfSBuf data) |
|
(const struct HdfDeviceIoClient client, uint32_t id, const struct data) |
|
HdfIoServiceBind (const char serviceName, mode_t permission) |
|
HdfIoServiceRecycle (struct service) |
Destroys a specified driver service object to release resources if it is no longer required. |
HdfDeviceRegisterEventListener (struct target, struct HdfDevEventlistener listener) |
Registers a custom for listening for events reported by a specified driver service object. |
HdfDeviceUnregisterEventListener (struct target, struct HdfDevEventlistener listener) |
Unregisters a previously registered to release resources if it is no longer required. |
HdfSbufWriteBuffer (struct sbuf, const void data, uint32_t writeSize) |
|
HdfSbufWriteUint64 (struct sbuf, uint64_t value) |
|
HdfSbufWriteUint32 (struct sbuf, uint32_t value) |
|
HdfSbufWriteUint16 (struct sbuf, uint16_t value) |
|
HdfSbufWriteUint8 (struct sbuf, uint8_t value) |
|
HdfSbufWriteInt64 (struct sbuf, int64_t value) |
|
HdfSbufWriteInt32 (struct sbuf, int32_t value) |
|
HdfSbufWriteInt16 (struct sbuf, int16_t value) |
|
HdfSbufWriteInt8 (struct sbuf, int8_t value) |
|
HdfSbufWriteString (struct sbuf, const char value) |
|
HdfSbufReadBuffer (struct sbuf, const void *data, uint32_t readSize) |
|
HdfSbufReadUint64 (struct sbuf, uint64_t value) |
|
HdfSbufReadUint32 (struct sbuf, uint32_t value) |
|
HdfSbufReadUint16 (struct sbuf, uint16_t value) |
|
HdfSbufReadUint8 (struct sbuf, uint8_t value) |
|
HdfSbufReadInt64 (struct sbuf, int64_t value) |
|
HdfSbufReadInt32 (struct sbuf, int32_t value) |
|
HdfSbufReadInt16 (struct sbuf, int16_t value) |
|
HdfSbufReadInt8 (struct sbuf, int8_t value) |
|
HdfSbufReadString (struct sbuf) |
|
HdfSbufGetData (const struct sbuf) |
|
HdfSbufFlush (struct sbuf) |
|
HdfSbufGetCapacity (const struct sbuf) |
|
HdfSbufGetDataSize (const struct sbuf) |
|
HdfSBufObtain (size_t capacity) |
|
HdfSBufObtainDefaultSize (void) |
Obtains a SBuf instance of the default capacity (256 bytes). |
HdfSBufBind (uintptr_t base, size_t size) |
Creates a SBuf instance with the specified data and size. The pointer to the data stored in the SBuf is released by the caller, and the written data size should not exceed the specified value of size. |
HdfSBufRecycle (struct sbuf) |
|
HdfSBufMove (struct sbuf) |
struct HdfSBuf Creates a SBuf instance with an original SBuf. This function moves the data stored in the original SBuf to the new one without memory copy. |
Creates a SBuf instance with an original SBuf. This function copies the data stored in the original SBuf to the new one. |
|
HdfSbufTransDataOwnership (struct sbuf) |
Transfers the data ownership to a SBuf. Once the SBuf is released, the bound data memory is also released. This function is used together with HdfSBufBind. |
Details
Macro Definition Documentation
HDF_INIT
Description:
Registers the driver with the HDF.
For a driver developed based on the HDF, HDF_INIT must be used to register an entry with the HDF, and the registered object must be of the type.
Parameters:
module | Indicates the global variable of the type |
Typedef Documentation
OnEventReceived
Description:
Called when a driver event occurs.
You can implement this function and bind it to the custom HdfDevEventlistener object.
Parameters:
priv | Indicates the pointer to the private data bound to this listener. |
id | Indicates the serial number of the driver event occurred. |
data | Indicates the pointer to the content data of the driver event. |
Returns:
Returns 0 if the operation is successful; returns a negative value otherwise.
Enumeration Type Documentation
DevicePreload
enum [DevicePreload]($api-api-SmartVision-Devices-Core.md#ga0f3d81b5ff5d3896f7d8cf15f76b451e)
Description:
Enumerates driver loading policies.
If a driver developed based on the HDF needs to use the on-demand loading mechanism in the HDF, the PRELOAD field must be correctly set in the driver configuration information to control the driver loading mode.
DEVICE_PRELOAD_ENABLE | |
DEVICE_PRELOAD_DISABLE | |
DEVICE_PRELOAD_INVALID |
ServicePolicy
enum [ServicePolicy]($api-api-SmartVision-Devices-Core.md#ga172844da8a6908bf7226eee703ad9f80)
Description:
Enumerates policies for releasing driver services developed based on the HDF.
If a driver is developed based on the HDF and uses the service management feature of the HDF, you need to configure the policy for releasing services to external systems.
Function Documentation
DevSvcManagerClntGetService()
const struct [HdfObject]($api-api-SmartVision-Devices-HdfObject.md)* DevSvcManagerClntGetService (const char * svcName)
Description:
Obtains the driver service object based on a driver service name.
Parameters:
serviceName | Indicates the pointer to the released driver service name. |
Returns:
Returns the driver service object if the operation is successful; returns NULL otherwise.
HdfDeviceGetServiceName()
const char* HdfDeviceGetServiceName (const struct [HdfDeviceObject]($api-api-SmartVision-Devices-HdfDeviceObject.md) * deviceObject)
Description:
Obtains the service name of a driver.
If a driver does not save its service name, it can use this function to obtain the service name.
Parameters:
deviceObject | Indicates the pointer to the driver device object. |
Returns:
Returns the service name if the operation is successful; returns NULL otherwise.
int HdfDeviceRegisterEventListener (struct [HdfIoService]($api-api-SmartVision-Devices-HdfIoService.md) * target, struct [HdfDevEventlistener]($api-api-SmartVision-Devices-HdfDevEventlistener.md) * listener )
Description:
Registers a custom HdfDevEventlistener for listening for events reported by a specified driver service object.
Parameters:
target | Indicates the pointer to the driver service object to listen, which is obtained through the HdfIoServiceBind function. |
listener | Indicates the pointer to the listener to register. |
Returns:
Returns 0 if the operation is successful; returns a negative value otherwise.
HdfDeviceSendEvent()
Description:
Sends event messages.
When the driver service invokes this function to send a message, all user-level applications that have registered listeners through HdfDeviceRegisterEventListener will receive the message.
Parameters:
deviceObject | Indicates the pointer to the driver device object. |
id | Indicates the ID of the message sending event. |
data | Indicates the pointer to the message content sent by the driver. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
HdfDeviceSendEventToClient()
int32_t HdfDeviceSendEventToClient (const struct [HdfDeviceIoClient]($api-api-SmartVision-Devices-HdfDeviceIoClient.md) * client, uint32_t id, const struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * data )
Description:
Sends an event message to a specified client object.
When the driver service invokes this function to send a message, the user-level applications that have registered listeners through and correspond to this client object will receive the message.
Parameters:
client | Indicates the pointer to the client object of the driver service. |
id | Indicates the ID of the message sending event. |
data | Indicates the pointer to the message content sent by the driver. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
HdfDeviceSubscribeService()
int32_t HdfDeviceSubscribeService (struct [HdfDeviceObject]($api-api-SmartVision-Devices-HdfDeviceObject.md) * deviceObject, const char * serviceName, struct [SubscriberCallback]($api-api-SmartVision-Devices-SubscriberCallback.md) callback )
Description:
Subscribes to a driver service.
If the driver loading time is not perceived, this function can be used to subscribe to the driver service. (The driver service and the subscriber must be on the same host.) After the subscribed-to driver service is loaded by the HDF, the framework proactively releases the service interface to the subscriber.
Parameters:
deviceObject | Indicates the pointer to the driver device object of the subscriber. |
serviceName | Indicates the pointer to the driver service name. |
callback | Indicates the callback invoked by the HDF after the subscribed-to driver service is loaded. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
HdfDeviceUnregisterEventListener()
int HdfDeviceUnregisterEventListener (struct [HdfIoService]($api-api-SmartVision-Devices-HdfIoService.md) * target, struct [HdfDevEventlistener]($api-api-SmartVision-Devices-HdfDevEventlistener.md) * listener )
Description:
Unregisters a previously registered HdfDevEventlistener to release resources if it is no longer required.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a negative value otherwise.
HdfIoServiceBind()
struct [HdfIoService]($api-api-SmartVision-Devices-HdfIoService.md)* HdfIoServiceBind (const char * serviceName, mode_t permission )
Description:
Obtains a driver service object.
Parameters:
Returns:
Returns the pointer to the driver service object if the operation is successful; returns NULL otherwise.
HdfIoServiceRecycle()
void HdfIoServiceRecycle (struct [HdfIoService]($api-api-SmartVision-Devices-HdfIoService.md) * service)
Description:
Destroys a specified driver service object to release resources if it is no longer required.
Parameters:
service | Indicates the pointer to the driver service object to destroy. |
HdfSBufBind()
struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md)* HdfSBufBind (uintptr_t base, size_t size )
Description:
Creates a SBuf instance with the specified data and size. The pointer to the data stored in the SBuf is released by the caller, and the written data size should not exceed the specified value of size.
Parameters:
base | Indicates the base of the data to use. |
size | Indicates the size of the data to use. |
Returns:
Returns the SBuf instance.
HdfSBufCopy()
Description:
Creates a SBuf instance with an original SBuf. This function copies the data stored in the original SBuf to the new one.
Parameters:
sbuf | Indicates the pointer to the original SBuf. |
Returns:
Returns the new SBuf instance.
HdfSbufFlush()
Description:
Clears the data stored in a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
HdfSbufGetCapacity()
size_t HdfSbufGetCapacity (const struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf)
Description:
Obtains the capacity of a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
Returns:
Returns the SBuf capacity.
HdfSbufGetData()
uint8_t* HdfSbufGetData (const struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf)
Description:
Obtains the pointer to the data stored in aSBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
Returns:
Returns the pointer to the data stored in the target SBuf.
HdfSbufGetDataSize()
size_t HdfSbufGetDataSize (const struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf)
Description:
Obtains the size of the data stored in a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
Returns:
Returns the data size.
HdfSBufMove()
struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md)* HdfSBufMove (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf)
Description:
Creates a SBuf instance with an original SBuf. This function moves the data stored in the original SBuf to the new one without memory copy.
Parameters:
sbuf | Indicates the pointer to the original SBuf. |
Returns:
Returns the new SBuf instance.
HdfSBufObtain()
struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md)* HdfSBufObtain (size_t capacity)
Description:
Obtains a SBuf instance.
Parameters:
capacity | Indicates the initial capacity of theSBuf. |
Returns the SBuf instance.
HdfSBufObtainDefaultSize()
struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md)* HdfSBufObtainDefaultSize (void )
Description:
Obtains a SBuf instance of the default capacity (256 bytes).
Returns:
Returns the SBuf instance.
HdfSbufReadBuffer()
bool HdfSbufReadBuffer (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, const void ** data, uint32_t * readSize )
Description:
Reads a data segment from a SBuf.
Parameters:
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufReadInt16()
bool HdfSbufReadInt16 (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, int16_t * value )
Description:
Reads a 16-bit signed integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 16-bit signed integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufReadInt32()
bool HdfSbufReadInt32 (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, int32_t * value )
Description:
Reads a 32-bit signed integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 32-bit signed integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufReadInt64 (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, int64_t * value )
Description:
Reads a 64-bit signed integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 64-bit signed integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufReadInt8()
bool HdfSbufReadInt8 (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, int8_t * value )
Description:
Reads an 8-bit signed integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 8-bit signed integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufReadString()
const char* HdfSbufReadString (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf)
Description:
Reads a string from a SBuf.
Parameters:
Returns:
Returns the pointer to the string read if the operation is successful; returns NULL otherwise. The memory pointed to by this pointer is managed by the SBuf and they share the same lifecycle.
HdfSbufReadUint16()
Description:
Reads a 16-bit unsigned integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 16-bit unsigned integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufReadUint32()
Description:
Reads a 32-bit unsigned integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 32-bit unsigned integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufReadUint64()
bool HdfSbufReadUint64 (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, uint64_t * value )
Description:
Reads a 64-bit unsigned integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 64-bit unsigned integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufReadUint8()
bool HdfSbufReadUint8 (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, uint8_t * value )
Description:
Reads an 8-bit unsigned integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 8-bit unsigned integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSBufRecycle()
void HdfSBufRecycle (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf)
Description:
Releases a SBuf .
Parameters:
sbuf | Indicates the pointer to the SBuf to release. |
HdfSbufTransDataOwnership()
void HdfSbufTransDataOwnership (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf)
Description:
Transfers the data ownership to a SBuf. Once the SBuf is released, the bound data memory is also released. This function is used together with .
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
HdfSbufWriteBuffer()
bool HdfSbufWriteBuffer (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, const void * data, uint32_t writeSize )
Description:
Writes a data segment to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
data | Indicates the pointer to the data segment to write. |
writeSize | Indicates the size of the data segment to write. The maximum value is 512 KB. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufWriteInt16()
bool HdfSbufWriteInt16 (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, int16_t value )
Description:
Writes a 16-bit signed integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 16-bit signed integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufWriteInt32()
bool HdfSbufWriteInt32 (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, int32_t value )
Description:
Writes a 32-bit signed integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 32-bit signed integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufWriteInt64()
bool HdfSbufWriteInt64 (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, int64_t value )
Description:
Writes a 64-bit signed integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 64-bit signed integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufWriteInt8()
bool HdfSbufWriteInt8 (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, int8_t value )
Description:
Writes an 8-bit signed integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 8-bit signed integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufWriteString()
bool HdfSbufWriteString (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, const char * value )
Description:
Writes a string to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the string to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufWriteUint16()
bool HdfSbufWriteUint16 (struct [HdfSBuf]($api-api-SmartVision-Devices-HdfSBuf.md) * sbuf, uint16_t value )
Description:
Writes a 16-bit unsigned integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 16-bit unsigned integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufWriteUint32()
Description:
Writes a 32-bit unsigned integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 32-bit unsigned integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufWriteUint64()
Description:
Writes a 64-bit unsigned integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 64-bit unsigned integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
HdfSbufWriteUint8()
Description:
Writes an 8-bit unsigned integer to a SBuf.
Parameters:
Returns: