com.webos.service.pdm
API Summary
Manages USB devices that are connected to the webOS system.
Main Functions:
- Mount/unmount of Mass Storage Class (MSC) USB devices
- Format, Fdisk, File system check (FSCK)
- Detect USB device
Supported USB Devices
- MSC USB device
- Supported file system: Windows compatible file system (FAT, NTFS)
- Supported device type: HDD, Memory Stick, SSD, Memory card
- Still image device (Picture Transfer Protocol (PTP) Camera)
- Camera
- HID & XPAD
- USB to Serial
Important Terms
- Device - A device that is directly connected to a USB port or hub.
- Drive - A device can have multiple drives, where each drive is a partition of a physical storage device.
Overview of the API
NA
Methods
eject
Description
Unmounts all drives of the storage device for safe removal.
Prerequisite: The storage device must be connected.
Parameters
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. |
Call Returns
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
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/eject '{"deviceNum":2}'
Response:
{
"returnValue": true
}
format
Description
Formats the connected drive.
Parameters
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 |
Call Returns
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
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
}
fsck
Description
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.
Parameters
Name | Required | Type | Description |
---|---|---|---|
driveName | Required | string | Indicates the information that can identify the drive. Example: sda1 |
Call Returns
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
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/fsck '{"driveName":"sda"}'
Response:
{
"returnValue":true
}
getAttachedDeviceStatus
Description
Gets the status information of connected device(s).
Parameters
Name | Required | Type | Description |
---|---|---|---|
subscribe | Required | boolean | Subscribe to get notified when the device status information changes. Possible values are:
|
Call Returns
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 | Required | Object: deviceStatusList | An array containing the status information of the device. |
Subscription Returns
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 | Required | Object: deviceStatusList | An array containing the status information of the device. |
Example
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
}
getAttachedNonStorageDeviceList
Description
Gets the status information of connected non-storage device(s).
Parameters
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:
|
Call Returns
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 | Required | String | Power-on status of the device. Note: This value always defaults to "normal". |
nonStorageDeviceList | Optional | Object: 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: videoDeviceList | An array of video device lists connected. Note: Returned only when "category" is "Video". |
audioDeviceList | Optional | Object: audioDeviceList | An array of audio device list connected. Note: Returned only when "category" is "Audio". |
netDeviceList | Optional | Object: netDeviceList | An array of net device list connected. Note: Returned only when "category" is "Net". |
Subscription Returns
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 | Required | String | Power-on status of the device. |
nonStorageDeviceList | Optional | Object: nonStorageDeviceList | An array containing the information about the non-storage device that is currently connected. |
videoDeviceList | Optional | Object: videoDeviceList | An array of video devices connected. |
audioDeviceList | Optional | Object: audioDeviceList | An array of audio devices connected. |
netDeviceList | Optional | Object: netDeviceList | An array of net devices connected. |
Example
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"
}
getAttachedStorageDeviceList
Description
Gets status information of connected storage device(s).
Parameters
Name | Required | Type | Description |
---|---|---|---|
subscribe | Required | boolean | Indicates if subscribed to get the notifications. Possible values are:
|
Call Returns
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 | Required | String | Indicates the power-on status of the device. Note: This value always defaults to "normal". |
storageDeviceList | Required | Object: storageDeviceList | Indicates an array containing information about the currently connected storage device(s). |
Subscription Returns
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 | Required | String | Power-on status of the device. Note: This value always defaults to "normal". |
storageDeviceList | Required | Object: storageDeviceList | An array containing information about the currently connected storage device(s). |
Example
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"
}
]
}
getSpaceInfo
Description
Gets the space information of the connected drive.
Note: The drive must be mounted.
Parameters
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:
|
Call Returns
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 | Required | Object: spaceInfo | Information about the drive space. |
Example
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
}
isWritableDrive
Description
Checks the file system attribute of the drive and returns whether it is writable.
Parameters
Name | Required | Type | Description |
---|---|---|---|
driveName | Required | String | Information that can identify the drive (e.g. sda1) |
Call Returns
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 | Required | boolean | Indicates if data can be written on the drive. Possible values are:
|
Example
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/isWritableDrive '{ "driveName" : "sda" }'
Response:
{
"returnValue":true,
"isWritable":true
}
setVolumeLabel
Description
Sets the volume label of the drive. It is supported only when file system type is FAT.
Parameters
Name | Required | Type | Description |
---|---|---|---|
driveName | Required | string | Information that can identify the drive (e.g. sda1) |
volumeLabel | Required | string | Volume label for the drive. |
Call Returns
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
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/setVolumeLabel '{ "driveName" : "sda", "volumeLabel" : "webos" }'
Response:
{
"returnValue":true
}
umountAllDrive
Description
Unmounts all drives.
Parameters
None
Call Returns
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
Example code
# luna-send -n 1 -f luna://com.webos.service.pdm/umountAllDrive '{}'
Response:
{
"returnValue":true
}
Objects
spaceInfo
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 (%) |
deviceStatusList
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: driveStatusList | List of statuses of the drives in the device |
driveStatusList
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 |
nonStorageDeviceList
List of information about the non-storage devices that are currently connected.
Name | Required | Type | Description |
---|---|---|---|
usbPortNum | Required | Number | Port number to which the device is connected |
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 |
productName | Required | String | Name of the device product |
devSpeed | Required | String | Speed of the device. Possible values are:
|
videoDeviceList
List of video device(s) connected.
Name | Required | Type | Description |
---|---|---|---|
productName | Required | String | Name of the product |
devSpeed | Required | String | Speed of the device |
deviceType | Required | String | Type of the USB device |
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. |
audioDeviceList
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 card |
usbPortNum | Required | Number | Port number where the sound device is connected |
devSpeed | Required | String | Speed of the sound device. Possible values are:
|
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. |
netDeviceList
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:
|
storageDeviceList
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: 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:
|
storageDriveList
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 |
subDeviceList
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 | Required | String | Name of the product. Note: Applicable only for Video category. |
capabilities | Required | String | Device capability attribute. Note: Applicable only for Video category. |
version | Required | 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. |
API Error Codes Reference
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 parse error | Json parse error |