Note
This API has been available since API level 11.
This API has been available since API level 11.
Manages USB devices that are connected to the webOS system.
Main Functions:
Supported USB Devices
Important Terms
NA
API level 11
Unmounts all drives of the storage device for safe removal.
Prerequisite: The storage device must be connected.
Name | Required | Type | Description |
---|---|---|---|
deviceNum | Required | Number | Indicates the unique identifier of the device. It is auto-assigned when the device is connected. Note: Use the getAttachedDeviceStatus() method to get a list of devices and their device numbers. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/eject '{"deviceNum":2}'
Response:
{
"returnValue": true
}
API level 11
Formats the connected drive.
Name | Required | Type | Description |
---|---|---|---|
driveName | Required | String | Indicates the information that can identify the drive. Example: sda1 |
fsType | Optional | String | Indicates the file system type. Possible values are:
Default: fat |
volumeLabel | Optional | String | Indicates the volume label for the drive. Default: volumeLabel not set |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Example: Formatting specific file system type and volume label
# luna-send -n 1 -f luna://com.webos.service.pdm/format '{
"driveName":"sda",
"fsType":"fat",
"volumeLabel":"test"
}'
Response:
{
"returnValue": true
}
Example: Formatting using the default values of file system type and volume label
# luna-send -n 1 -f luna://com.webos.service.pdm/format '{"driveName":"sda1"}'
Response:
{
"returnValue": true
}
API level 11
Checks the file system by performing fsck (File System Check) of the corresponding connected drive.
Note: On connecting a USB device with a large number of files, the PDM service prompts for “Check & Repair” and “Open Now”. The fsck() API will do the file system checking when “Check & Repair” is selected.
Name | Required | Type | Description |
---|---|---|---|
driveName | Required | String | Indicates the information that can identify the drive. Example: sda1 |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/fsck '{"driveName":"sda"}'
Response:
{
"returnValue":true
}
API level 11
Gets the status information of connected device(s).
Name | Required | Type | Description |
---|---|---|---|
subscribe | Required | Boolean | Subscribe to get notified when the device status information changes. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
deviceStatusList | Optional | Object array: deviceStatusList | An array containing the status information of the device. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
deviceStatusList | Optional | Object array: deviceStatusList | An array containing the status information of the device. |
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/getAttachedDeviceStatus '{ "subscribe" : true}'
Response:
{
"deviceStatusList": [
{
"productName": "USB Optical Mouse",
"deviceType": "HID",
"deviceNum": 3,
"deviceStatus": "NOTHING",
"vendorName": "PixArt",
"usbInfoString": "3-1.2.4",
"usbPortNum": 3
},
{
"productName": "USB Audio",
"deviceType": "HID",
"deviceNum": 4,
"deviceStatus": "NOTHING",
"vendorName": "Generic",
"usbInfoString": "3-1.3",
"usbPortNum": 48
},
{
"driveStatusList": [
{
"driveName": "apps",
"driveStatus": "MOUNT_OK "
}
],
"deviceType": "INTERNAL",
"deviceNum": 0,
"deviceStatus": "NOTHING"
},
{
"productName": "USB Audio",
"deviceType": "SOUND",
"deviceNum": 4,
"deviceStatus": "NOTHING",
"vendorName": "Realtek Semiconductor Corp.",
"usbInfoString": "3-1.3",
"usbPortNum": 48
},
{
"deviceStatus": "NOTHING",
"productName": "Mass Storage Device",
"driveStatusList": [
{
"driveName": "sda1",
"driveStatus": "MOUNT_OK "
}
],
"deviceType": "USB_STORAGE",
"deviceNum": 2,
"usbPortNum": 1,
"usbInfoString": "5-1",
"vendorName": "Transcend Information, Inc."
}
],
"returnValue": true
}
API level 11
Gets the status information of connected non-storage device(s).
Name | Required | Type | Description |
---|---|---|---|
subscribe | Required | Boolean | Subscribe to get notified when a device is connected and the list of non-storage device changes. Possible values are:
|
category | Optional | String | Category of non-storage device. Possible values are:
|
groupSubDevices | Optional | Boolean | Indicates grouping of sub devices. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
powerStatus | Optional | String | Power-on status of the device. Note: This value always defaults to "normal". |
nonStorageDeviceList | Optional | Object array: nonStorageDeviceList | An array containing the information about the non-storage device that is currently connected. Note: Returned only when "category" is NOT provided. |
videoDeviceList | Optional | Object array: videoDeviceList | An array of video device lists connected. Note: Returned only when "category" is "Video". |
audioDeviceList | Optional | Object array: audioDeviceList | An array of audio device list connected. Note: Returned only when "category" is "Audio". |
netDeviceList | Optional | Object array: netDeviceList | An array of net device list connected. Note: Returned only when "category" is "Net". |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
powerStatus | Optional | String | Power-on status of the device. Note: This value always defaults to "normal". |
nonStorageDeviceList | Optional | Object array: nonStorageDeviceList | An array containing the information about the non-storage device that is currently connected. Note: Returned only when "category" is NOT provided. |
videoDeviceList | Optional | Object array: videoDeviceList | An array of video devices connected. Note: Returned only when "category" is "Video". |
audioDeviceList | Optional | Object array: audioDeviceList | An array of audio devices connected. Note: Returned only when "category" is "Audio". |
netDeviceList | Optional | Object array: netDeviceList | An array of net devices connected. Note: Returned only when "category" is "Net". |
Example: To view all non-storage devices attached
# luna-send -n 1 -f luna://com.webos.service.pdm/getAttachedNonStorageDeviceList '{ "subscribe" : true }'
Response:
{
"powerStatus": "normal",
"nonStorageDeviceList": [
{
"usbPortNum": 255,
"serialNumber": "",
"isPowerOnConnect": false,
"deviceNum": 52,
"deviceSubtype": "usbhid",
"vendorName": "DELL",
"deviceType": "HID",
"productName": "Dell USB Entry Keyboard",
"devSpeed": "LOW"
},
{
"usbPortNum": 2,
"serialNumber": "",
"isPowerOnConnect": false,
"deviceNum": 62,
"deviceSubtype": "usbhid",
"vendorName": "17ef",
"deviceType": "HID",
"productName": "Lenovo Optical USB Mouse",
"devSpeed": "LOW"
}
],
"returnValue": true
}
Example: To view all non-storage (audio) devices attached
# luna-send -n 1 -f luna://com.webos.service.pdm/getAttachedNonStorageDeviceList '{ "subscribe" : true, "category" : "Audio" }'
Response:
{
"powerStatus": "normal",
"audioDeviceList": [
{
"cardNumber": 2,
"cardName": "USB PnP Sound Device",
"cardId": "Device",
"builtin": false,
"usbPortNum": 3,
"devSpeed": "HIGH"
}
],
"returnValue": true
}
Example: To view all non-storage (net) devices attached
# luna-send -n 1 -f luna://com.webos.service.pdm/getAttachedNonStorageDeviceList '{ "subscribe" : true, "category" : "Net" }'
Response:
{
"netDeviceList": [
{
"duplex": "",
"ifindex": "4",
"linkmode": "0",
"address": "50:3e:aa:6d:65:e5",
"vendorName": "TP-LINK",
"productName": "USB 10 100 1000 LAN",
"devSpeed": "HIGH",
"operstate": "down"
}
],
"powerStatus": "normal",
"returnValue": true
}
Example : To view information about connected video device(s)
# luna-send -n 1 -f luna://com.webos.service.pdm/getAttachedNonStorageDeviceList '{
"subscribe" : true,
"category" : "Video",
"groupSubDevices" : true
}'
Response:
{
"returnValue": true,
"videoDeviceList": [
{
"subDeviceList": [
{
"productName": "C270 HD WEBCAM",
"capabilities": ":capture:",
"version": "2",
"devPath": "/dev/video0"
},
{
"productName": "C270 HD WEBCAM",
"capabilities": ":",
"version": "2",
"devPath": "/dev/video1"
}
],
"productName": "C270 HD WEBCAM",
"devSpeed": "HIGH",
"deviceType": "CAM",
"vendorName": "Logitech, Inc."
}
],
"powerStatus": "normal"
}
Example : To view information about connected audio device(s)
# luna-send -i -f luna://com.webos.service.pdm/getAttachedNonStorageDeviceList '{
"subscribe" : true,
"category" : "Audio",
"groupSubDevices" : true
}'
Response:
{
"audioDeviceList": [
{
"subDeviceList": [
{
"deviceType": "playback",
"devPath": "/dev/snd/pcmC0D0p"
},
{
"deviceType": "control",
"devPath": "/dev/snd/controlC0"
}
],
"devSpeed": "",
"cardNumber": 0,
"cardId": "b1",
"built-in": true,
"cardName": "bcm2835 HDMI 1",
"usbPortNum": 0
},
{
"subDeviceList": [
{
"deviceType": "playback",
"devPath": "/dev/snd/pcmC1D0p"
},
{
"deviceType": "control",
"devPath": "/dev/snd/controlC1"
}
],
"devSpeed": "",
"cardNumber": 1,
"cardId": "Headphones",
"built-in": true,
"cardName": "bcm2835 Headphones",
"usbPortNum": 0
},
{
"subDeviceList": [
{
"deviceType": "control",
"devPath": "/dev/snd/controlC2"
},
{
"deviceType": "capture",
"devPath": "/dev/snd/pcmC2D0c"
},
{
"deviceType": "playback",
"devPath": "/dev/snd/pcmC2D0p"
}
],
"devSpeed": "FULL",
"cardNumber": 2,
"cardId": "Device",
"built-in": false,
"cardName": "USB PnP Sound Device",
"usbPortNum": 0
}
],
"returnValue": true,
"powerStatus": "normal"
}
API level 11
Gets status information of connected storage device(s).
Name | Required | Type | Description |
---|---|---|---|
subscribe | Required | Boolean | Indicates if subscribed to get the notifications. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
powerStatus | Optional | String | Indicates the power-on status of the device. Note: This value always defaults to "normal". |
storageDeviceList | Optional | Object array: storageDeviceList | Indicates an array containing information about the currently connected storage device(s). |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
powerStatus | Optional | String | Power-on status of the device. Note: This value always defaults to "normal". |
storageDeviceList | Optional | Object array: storageDeviceList | An array containing information about the currently connected storage device(s). |
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/getAttachedStorageDeviceList '{ "subscribe" : true }'
Response:
{
"powerStatus":"normal",
"returnValue":true,
"storageDeviceList":[
{
"usbPortNum":2,
"rootPath":"/tmp/usb/sdb",
"storageDriveList":[
{
"isMounted":true,
"volumeLabel":"MX-ES",
"uuid":"1209-3C50",
"driveName":"sdb1",
"driveSize":31190064,
"fsType":"fat",
"mountName":"/tmp/usb/sdb/sdb1"
}
],
"serialNumber":"000000000000000236",
"isPowerOnConnect":false,
"deviceNum":2,
"vendorName":"MX",
"storageType":"FLASH",
"deviceType":"USB_STORAGE",
"productName":"Mass Storage Device",
"devSpeed":"HIGH",
"errorReason":"NOTHING"
}
]
}
API level 27
Provides debug logs with detailed information of all connected storage and non-storage device list.
None
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
Example scenario
# luna-send -n 1 -f luna://com.webos.service.pdm/getExample '{ }'
Response:
{
"returnValue": true
}
API level 11
Gets the space information of the connected drive.
Note: The drive must be mounted.
Name | Required | Type | Description |
---|---|---|---|
driveName | Required | String | Information that can identify the drive (e.g. sda1) |
directCheck | Optional | Boolean | Indicates if PDM needs to newly measure the drive space information at the time of API call. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
spaceInfo | Optional | Object: spaceInfo | Information about the drive space. |
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/getSpaceInfo '{ "driveName" : "sda" , "directCheck" : true }'
Response:
{
"spaceInfo":{
"usedRate":0,
"freeSize":31116080.000000,
"totalSize":31190064.000000,
"usedSize":73984.000000
},
"returnValue":true
}
API level 11
Checks the file system attribute of the drive and returns whether it is writable.
Name | Required | Type | Description |
---|---|---|---|
driveName | Required | String | Information that can identify the drive (e.g. sda1) |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
isWritable | Optional | Boolean | Indicates if data can be written on the drive. Possible values are:
|
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/isWritableDrive '{ "driveName" : "sda" }'
Response:
{
"returnValue":true,
"isWritable":true
}
API level 23
Mounts the device without performing Fsck.
Alternatively, it can be configured to perform Fsck and then mount the device.
Name | Required | Type | Description |
---|---|---|---|
mountName | Required | String | USB device name (If the device detected by /dev/sda, the device name is sda). |
needFsck | Optional | Boolean | Indicates whether Fsck is needed. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details |
Example scenario
# luna-send -n 1 -f luna://com.webos.service.pdm/mountandFullFsck'{ "mountName" : "sda"}'
Response:
{
"returnValue":true
}
Example : With needFsck parameter
# luna-send -n 1 -f luna://com.webos.service.pdm/mountandFullFsck '{"mountName" : "sda", "needFsck" : false }'
Response:
{
"returnValue": true
}
API level 11
Sets the volume label of the drive. It is supported only when file system type is FAT.
Name | Required | Type | Description |
---|---|---|---|
driveName | Required | String | Information that can identify the drive (e.g. sda1) |
volumeLabel | Required | String | Volume label for the drive. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/setVolumeLabel '{ "driveName" : "sda", "volumeLabel" : "webos" }'
Response:
{
"returnValue":true
}
API level 11
Unmounts all drives.
None
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details. |
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/umountAllDrive '{}'
Response:
{
"returnValue":true
}
List of audio device(s) connected.
Name | Required | Type | Description |
---|---|---|---|
cardNumber | Required | Number | Card number of the audio device |
cardName | Required | String | Name of the audio device card |
cardId | Required | String | Type of the audio device. e.g. Headphone, Wireless. |
usbPortNum | Required | Number | Port number where the sound device is connected, it gives -1 for internal devices. |
devSpeed | Required | String | Speed of the sound device. Possible values are:
Note : It will be LOW for built-in devices |
builtin | Required | Boolean | Indicates the status of device. Possible values are:
|
subDeviceList | Optional | Object array: subDeviceList | Contains info of sub-devices Note: Sub-devices are multiple sound devices inside single device. e.g. one sound card may have control, playback and capture sub devices. |
An array containing information about the currently connected device(s).
Name | Required | Type | Description |
---|---|---|---|
storageDeviceList | Optional | Object array: storageDeviceList | List of information about the storage devices that are currently connected. |
nonStorageDeviceList | Optional | Object array: nonStorageDeviceList | List of information about the non-storage devices that are currently connected. |
List of the storage and non-storage devices connected and their statuses.
Name | Required | Type | Description |
---|---|---|---|
deviceNum | Required | Number | Device number |
deviceStatus | Required | String | Status of the device |
driveStatusList | Optional | Object array: driveStatusList | List of statuses of the drives in the device |
productName | Optional | String | Name of the device product. |
usbPortNum | Optional | Number | Port number where the sound device is connected, it gives -1 for internal devices. |
vendorName | Optional | String | Name of the device vendor. |
List of the drives in the connected storage devices and their statuses.
Name | Required | Type | Description |
---|---|---|---|
driveName | Required | String | Name of the drive |
driveStatus | Required | String | Mount status of the drive |
List of Communication Device Class (CDC) device(s) connected.
Name | Required | Type | Description |
---|---|---|---|
operstate | Required | String | State of the device operation |
ifindex | Required | String | Network interface index |
linkmode | Required | String | Tells whether specified interface is managed and configured by systemd network manager. Possible values are:
|
duplex | Required | String | Bandwidth of the device. Possible values are:
|
address | Required | String | Ethernet address of the device connected |
vendorName | Required | String | Name of the vendor |
productName | Required | String | Name of the product |
devSpeed | Required | String | Speed of the device. Possible values are:
|
List of information about the non-storage devices that are currently connected.
Name | Required | Type | Description |
---|---|---|---|
usbPortNum | Required | Number | Port number where the sound device is connected, it gives -1 for internal devices. |
serialNumber | Required | String | Serial number of the device product |
isPowerOnConnect | Required | Boolean | Indicates whether the device was connected during power on. Possible values are:
|
deviceNum | Required | Number | Number assigned to the connected device |
deviceSubtype | Required | String | Sub-type of the device connected. For example: If deviceType is "usb", then deviceSubtype can be "usbhid" etc. |
vendorName | Required | String | Name of the device vendor |
deviceType | Required | String | Type of the device. e.g : USB, HID, CAM etc |
productName | Required | String | Name of the device product |
devSpeed | Required | String | Speed of the device. Possible values are:
Note : It will be LOW for built-in devices.. |
Information about the drive space.
Name | Required | Type | Description |
---|---|---|---|
totalSize | Required | Number (double) | Total Drive Size (KB) |
usedSize | Required | Number (double) | Drive size currently in use (KB) |
freeSize | Required | Number (double) | Currently Available Drive Size (KB) |
usedRate | Required | Number (int32_t) | Current Drive Utilization (%) |
List of information about the storage devices that are currently connected.
Name | Required | Type | Description |
---|---|---|---|
usbPortNum | Required | Number | Port number to which the device is connected. |
rootPath | Required | String | Root directory path of the device. |
storageDriveList | Required | Object array: storageDriveList | List of storage drives in the connected storage device. |
serialNumber | Required | String | Serial number of the device. |
isPowerOnConnect | Required | Boolean | Indicates whether the device was connected during power on. Possible values are:
|
deviceNum | Required | Number | Number assigned to the device. |
vendorName | Required | String | Name of the vendor. |
storageType | Required | String | Type of the storage device. |
deviceType | Required | String | Type of the USB device. |
productName | Required | String | Name of the product. |
devSpeed | Required | String | Speed of the device. |
errorReason | Required | String | Describes the status of device mounting. Possible values are:
|
List of the drives in storage devices connected.
Name | Required | Type | Description |
---|---|---|---|
isMounted | Required | Boolean | Indicates whether the device is mounted or not. Possible values are:
|
volumeLabel | Required | String | Label set for the drive in the device |
uuid | Required | String | Unique SCSI device ID |
driveName | Required | String | Name of the drive where mounted |
driveSize | Required | Number | Size of the drive |
fsType | Required | String | Type of the file system in the drive |
mountName | Required | String | Absolute path of the drive in the device where mounted |
Contains info of sub-devices
Note: Sub-devices are multiple camera or sound devices inside single camera or sound device.
Name | Required | Type | Description |
---|---|---|---|
productName | Optional | String | Name of the product. Note: Applicable only for Video category. |
capabilities | Optional | String | Device capability attribute. Note:
|
version | Optional | String | Version of the product. Note: Applicable only for Video category. |
devPath | Required | String | Path of the device. Note: Applicable for Video and Audio category. |
deviceType | Optional | String | Audio sub device type based on sub-device functionality. For example, playback, capture, control, misc. Note: Applicable only for Audio category. |
List of video device(s) connected.
Name | Required | Type | Description |
---|---|---|---|
productName | Required | String | Name of the product |
devSpeed | Required | String | Speed of the sound device. Possible values are:
Note : It will be LOW for built-in devices. |
deviceType | Required | String | Type of the USB device. Possible values : CAM |
vendorName | Required | String | Name of the vendor |
subDeviceList | Optional | Object array: subDeviceList | Contains info of sub-devices Note: Sub-devices are multiple camera devices inside single camera. |
SUBSYSTEM | Optional | String | Indicates SUBSYSTEM of device. |
KERNEL | Optional | String | Indicates KERNEL of the device. |
Error Code | Error Text | Error Description |
---|---|---|
1 | Parameter error | Parameter error |
2 | Interface function error | Interface function error |
3 | Subscribe Error | Subscribe Error |
4 | SubscriptionAdd Fail | SubscriptionAdd Fail |
5 | LSSubscriptionAcquire Fail | LSSubscriptionAcquire Fail |
6 | Json message parse error | Json parse error |
Contents