com.webos.service.peripheralmanager
API Summary
The peripheralmanager is a service to provide APIs to monitor sensors and control actuators connected to I/O peripherals using industry-standard protocols.
Currently, supported protocols are UART ,GPIO, SPI and I2C.
This service manages parallel requests from multiple applications to access peripherals and control the hardware.
Overview of the API
NA
Methods
gpio/list
Description
Provides the list of available GPIO pins in the target hardware.
Parameters
Name | Required | Type | Description |
---|---|---|---|
subscribe | Optional | Boolean | Indicates if subscribed to get notified when there is a change in available pins. Possible values are:
Default: false |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
subscribed | Optional | Boolean | Indicates if subscribed to get notifications. Possible values are:
|
gpioList | Optional | Object array: gpioList | List of available GPIO pins with the status. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
Example without Subscription
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/list '{}'
Response:
{
"subscribed":false,
"returnValue":true,
"gpioList":[
{
"pin":"gpio12",
"status":"available"
},
{
"pin":"gpio13",
"status":"available"
},
{
"pin":"gpio16",
"status":"available"
},
{
"pin":"gpio17",
"status":"available"
},
{
"pin":"gpio18",
"status":"available"
},
{
"pin":"gpio19",
"status":"available"
},
{
"pin":"gpio20",
"status":"available"
},
{
"pin":"gpio21",
"status":"available"
},
{
"pin":"gpio22",
"status":"available"
},
{
"pin":"gpio23",
"status":"available"
},
{
"pin":"gpio24",
"status":"available"
},
{
"pin":"gpio25",
"status":"available"
},
{
"pin":"gpio4",
"status":"available"
},
{
"pin":"gpio5",
"status":"available"
},
{
"pin":"gpio6",
"status":"available"
}
]
}
gpio/open
Description
Opens the GPIO pin, if not already opened by other applications.
Parameters
Name | Required | Type | Description |
---|---|---|---|
pin | Required | String | ID of the pin. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
Example Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/open ' {"pin":"gpio4"}'
Response:
{
"returnValue": true
}
gpio/getDirection
Description
Returns the direction of the required GPIO pin.
Parameters
Name | Required | Type | Description |
---|---|---|---|
pin | Required | String | ID of the pin. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
direction | Optional | String | Indicates the direction of the pin. |
Example
Example scenario
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/getDirection '{"pin":"gpio4"}'
Response:
{
"returnValue": true,
"direction": "out"
}
gpio/setDirection
Description
Sets the direction of the GPIO pin to input or output
Parameters
Name | Required | Type | Description |
---|---|---|---|
pin | Required | String | ID of the pin. |
direction | Required | String | Direction of the pin. Possible values are: "in", "outLow", "outHigh" |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
Example Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/setDirection ' {"pin":"gpio4", "direction":"outHigh"}'
Response:
{
"returnValue": true
}
gpio/getPollingFd
Description
Returns the file descriptor for the GPIO pin specified in the input.
Parameters
Name | Required | Type | Description |
---|---|---|---|
id | Required | String | ID of the pin. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
fd | Optional | String | File descriptor of the interface. |
Example
Example Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/getPollingFd '{"id" : "gpio4"}'
Response:
{
"fd": 8,
"returnValue": true
}
gpio/getValue
Description
Reads the value of the opened input pin
Parameters
Name | Required | Type | Description |
---|---|---|---|
pin | Required | String | ID of the pin. |
subscribe | Optional | Boolean | Indicates if subscribed to get notified when there is a change in value. Possible values are:
Default: false |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
subscribed | Optional | Boolean | Indicates if subscribed to get notifications. Possible values are:
|
value | Optional | String | Indicates the value. Possible values are: "low" or "high". |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
Example Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/getValue '{"pin":"gpio4"}'
Response:
{
"subscribed": false,
"returnValue": true,
"value": "low"
}
gpio/setValue
Description
Sets the value of the opened output pin to "low" or "high"
Parameters
Name | Required | Type | Description |
---|---|---|---|
pin | Required | String | ID of the pin. |
value | Required | String | Value of the output pin. Possible values are: "low" or "high". |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
Example Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/setValue ' {"pin":"gpio4", "value":"low"}'
Response:
{
"returnValue": true
}
gpio/close
Description
Closes the opened GPIO pin, so that the pin is available for other applications to use.
Parameters
Name | Required | Type | Description |
---|---|---|---|
pin | Required | String | ID of the pin. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
Example Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/close '{"pin":"gpio4"}'
Response:
{
"returnValue": true
}
uart/list
Description
Provides the list of available UART interfaces in the target hardware.
Parameters
Name | Required | Type | Description |
---|---|---|---|
subscribe | Optional | Boolean | Indicates if subscribed to get notified when there is a change in available interfaces. Possible values are:
Default: false |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
subscribed | Optional | String | Indicates if subscribed to get notifications. Possible values are:
|
uartList | Optional | Object array: uartList | List of available UART interfaces. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
Example without Subscription
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/list '{}'
Response:
{
"subscribed":false,
"returnValue":true,
"uartList":[
{
"status":"used",
"interfaceId":"UART1"
}
]
}
uart/open
Description
Opens the UART interface, if not already opened by other applications.
Parameters
Name | Required | Type | Description |
---|---|---|---|
interfaceId | Required | String | ID of the UART interface. |
config | Optional | Object: config | The configurations to be set for the opened UART Interface. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
Example : Open the UART interface
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/open '{"interfaceId":"UART1"}'
Response:
{
"returnValue": true
}
Example : Set configs for opened UART interface
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/open '{"interfaceId":"ttyACM0", "config":{"canonical" : true}}'
Response:
{
"returnValue": true
}
uart/getBaudrate
Description
Reads the baud rate of the opened UART device.
Parameters
Name | Required | Type | Description |
---|---|---|---|
interfaceId | Required | String | ID of the UART interface. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
baudrate | Optional | Number | Value of the baud rate. |
Example
getBaudrate
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/getBaudrate '{"interfaceId":"UART1"}'
Response:
{
"returnValue": true,
"baudrate": 9600
}
uart/setBaudrate
Description
Sets the baud rate of the opened UART device to the required value.
Parameters
Name | Required | Type | Description |
---|---|---|---|
interfaceId | Required | String | ID of the UART interface. |
baudrate | Required | Number | Value of the baud rate. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | String | The error code for the failed operation. |
returnValue | Required | String | The status of the operation. Possible values are:
|
Example
setBaudrate
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/setBaudrate '{"interfaceId":"UART1", "baudrate":9600}'
Response:
{
"returnValue": true
}
uart/getPollingFd
Description
Returns the file descriptor for the UART interface specified in the input.
Parameters
Name | Required | Type | Description |
---|---|---|---|
id | Required | String | ID of the UART interface. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
fd | Optional | String | File descriptor of the interface. |
Example
getPollingFd
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/getPollingFd '{"id" : "UART1"}'
Response:
{
"fd": 7,
"returnValue": true
}
uart/read
Description
Reads the data from the opened UART device.
Parameters
Name | Required | Type | Description |
---|---|---|---|
interfaceId | Required | String | ID of the UART interface. |
dataType | Optional | String | The format of data to be returned. |
size | Optional | Number | Size of the data to be read. If not specified, all available data is read. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
data | Optional | String | Value read from the opened UART interface. |
dataType | Optional | String | Type of data in the data field. |
Example
Example : Read data from the UART interface
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/read '{"interfaceId":"ttyACM0", "dataType":"text"}'
Response:
{
"data": "Temperature(Celcius)\":30.6598,\"Humidity(%rH)\":71.40324,\"GasResistance(Ohms)\":659577,\"sensorName\":\"Arduino_BME680\"}}\r\n",
"returnValue": true,
"dataType": "text"
}
uart/write
Description
Writes the data to the opened UART device.
Parameters
Name | Required | Type | Description |
---|---|---|---|
interfaceId | Required | String | ID of the UART interface. |
data | Required | String | Data to write into the UART device. |
dataType | Required | String | Type of data in the data field. |
size | Required | String | Size of the data passed to be written. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
size | Optional | Number | Size of the data written to the device. |
Example
Example : Write to the UART interface
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/write '{
"interfaceId":"ttyACM0",
"data": "xyzabc",
"dataType":"text",
"size":6
}'
Response:
{
"returnValue": true,
"size": 6
}
uart/close
Description
Closes the opened UART device so that the interface is available for other apps to use.
Parameters
Name | Required | Type | Description |
---|---|---|---|
interfaceId | Required | String | ID of the UART interface. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
Example Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/close '{"interfaceId":"UART1"}'
Response:
{
"returnValue": true
}
i2c/list
Description
Provides the list of available I2C buses.
Parameters
Name | Required | Type | Description |
---|---|---|---|
verbose | Optional | Boolean | Provide a list of I2C buses with slaveAddress and more details. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
i2cList | Optional | String array | List of I2C buses. If verbose input parameter is set, also returns the slave address. |
Example
Example : List of available I2C buses without verbose
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/list '{}'
Response:
{
"returnValue": true,
"i2cBusList": [
"I2C1",
"I2C4"
]
}
Example : List of available I2C buses with verbose
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/list '{"verbose":true}'
Response:
{
"returnValue": true,
"i2cBusList": [
{
"slaveAddress": [
"66",
"77"
],
"name": "I2C1"
},
{
"slaveAddress": [
"66",
"77"
],
"name": "I2C4"
}
]
}
i2c/open
Description
Opens the device connected to I2C bus.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C interface. |
address | Required | Number | Address of the I2C device to be opened, which is connected to the I2C bus |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
open
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/open '{"name":"I2C1", "address":104}'
Response:
{
"returnValue": true
}
i2c/read
Description
Reads data from the I2C device.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C device. |
address | Required | String | Address of the device that is being used. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
size | Optional | Number | Size of the data read. |
data | Optional | Object array | Data read from the device. |
Example
read
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/read '{"name":"I2C1", "address":104, "size":4}'
Response:
{
"data": [
4,
18,
1,
0
],
"returnValue": true,
"size": 4
}
i2c/readRegByte
Description
Reads a byte from a given register of the I2C device.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C interface. |
address | Required | Number | Address of the I2C device connected to the interface. |
reg | Required | Number | Register address. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
data | Optional | Number | Read value from the register. |
Example
readRegByte
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/readRegByte '{"name":"I2C1","address":104, "reg":0}'
Response:
{
"data": 22,
"returnValue": true
}
i2c/readRegWord
Description
Reads a word from the register of the i2c device.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C interface. |
address | Required | Number | Address of the I2C device connected to the interface. |
reg | Required | Number | Register address. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
data | Optional | Number | Read value from the register. |
Example
Example scenario
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/readRegWord '{"name":"I2C1","address":104, "reg":0}'
Response:
{
"data": 1111,
"returnValue": true
}
i2c/readRegBuffer
Description
Reads a value from the register buffer.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C interface. |
address | Required | Number | Address of the I2C device connected to the interface. |
reg | Required | Number | Register address. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
data | Optional | Object array | Data read. |
Example
readRegBuffer
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/readRegBuffer '{"name":"I2C1", "address":104, "reg":0, "size":4}'
Response:
{
"data": [
1,
2,
3,
4
],
"returnValue": true,
"size": 4
}
i2c/write
Description
Writes the data to the opened I2C device.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C interface. |
address | Required | Number | Address of the I2C device connected to the interface. |
data | Required | Object array | Data to be written. |
size | Optional | Number | Size of data to be written. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
size | Optional | Number | Bytes written. |
Example
write
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/write '{"name":"I2C1", "address":104, "data":[1,2,3,4]}'
Response:
{
"returnValue": true,
"size": 4
}
i2c/writeRegByte
Description
Writes a byte from a given register.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C interface. |
address | Required | Number | Address of the I2C device connected to the interface. |
reg | Required | Number | Register address. |
data | Required | Number | Data to write into register. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Number | The status of the operation. Possible values are:
|
Example
writeRegByte
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/writeRegByte '{"name":"I2C1", "address":104, "reg":0, "data":22}'
Response:
{
"returnValue": true
}
i2c/writeRegWord
Description
Writes a word to the register of the I2C device.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C interface. |
address | Required | Number | Address of the I2C device connected to the interface. |
reg | Required | Number | Register address. |
data | Required | Number | Data to write into register. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
writeRegWord
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/writeRegWord '{"name":"I2C1","address":104, "reg":0, "data":1111}'
Response:
{
"returnValue": true
}
i2c/writeRegBuffer
Description
Writes data to the register buffer of the connected I2C device.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C interface. |
address | Required | Number | Address of the I2C device connected to the interface. |
reg | Required | Number | Register address. |
data | Required | Object array | Data that needs to be written. |
size | Required | Number | Size of the data. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
size | Required | Number | Bytes to be written into register. |
Example
writeRegBuffer
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/writeRegBuffer '{"name":"I2C1", "address":104, "reg":0, "data":[1,2,3,4]}'
Response:
{
"returnValue": true,
"size": 4
}
i2c/getPollingFd
Description
Returns the file descriptor for the I2c if specified in the input.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C pin. |
address | Required | Number | Address of the I2C device connected to the interface. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | Indicates the status of operation.Possible values are: |
fd | Optional | String | File descriptor of the interface. |
Example
/i2c/getPollingFd
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/getPollingFd '{"name" : "I2C1", "address" :104}'
Response:
{
"fd": 10,
"returnValue": true
}
i2c/close
Description
Closes the opened I2C device connected to the bus.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C interface. |
address | Required | Number | Address of the I2C device to be closed, which is connected to the I2C bus. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
Example scenario
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/close '{"name":"I2C1", "address":104}'
Response:
{
"returnValue": true
}
spi/list
Description
Provides the list of available SPI buses in the target hardware.
Parameters
None
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
list | Optional | String array | List of available SPI buses. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
list
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/list '{}'
Response:
{
"returnValue": true,
"list": [
"SPI00"
]
}
spi/open
Description
Opens the SPI bus, if not already opened by other applications.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | ID of the SPI bus interface. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
open
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/open '{"name" :"SPI00"}'
Response:
{
"returnValue": true
}
spi/setMode
Description
Sets modes that correspond to the possible clocking configurations.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | ID of the SPI interface. |
mode | Required | Number | Mode to be set for the SPI device (possible values: 0 to 3). |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
setMode
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setMode '{"name":"SPI00", "mode":0}'
Response:
{
"returnValue": true
}
spi/writeByte
Description
Writes a byte of data to the SPI device connected to the bus.
Parameters
Name | Required | Type | Description |
---|---|---|---|
data | Required | Number | Data to be written. |
name | Required | String | ID of the SPI interface. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
writeByte
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/writeByte '{"name":"SPI00", "data":10}'
Response:
{
"returnValue": true
}
spi/writeBuffer
Description
Writes a chunk of data to SPI device.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | ID of the SPI interface. |
data | Required | Object array | Data to be written to the SPI device. |
size | Required | Number | Size of the data. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
size | Optional | Number | Size of the data written to the device. |
Example
writeBuffer
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/writeBuffer '{"name":"SPI00", "data":[1,2,3,4]}'
Response:
{
"returnValue": true,
"size": 4
}
spi/transfer
Description
Opens a connection for receiving/transmitting data to/from a particular slave device.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | ID of the SPI interface. |
data | Optional | Object array | Data to be transferred to the SPI device. |
size | Required | Number | Size of the data to be written/read, if data field is not present. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
tx_size | Optional | Number | Size of the data transferred to the SPI device. |
rx_size | Optional | Number | Size of the data read from the SPI device. |
rx_data | Optional | Object array | Receiving of the data from slave. |
Example
transfer
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/transfer '{"name":"SPI00", "data":[1,2,3,4], "size":4}'
Response:
{
"returnValue": true,
"rx_size": 4,
"tx_size": 4,
"rx_data": [
1,
2,
3,
4
]
}
spi/setFrequency
Description
Sets the rate of data transfer (Hz)
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | ID of the SPI interface. |
frequency | Required | Number | Setting the frequency of the bus upto value that is allowed based on the bus max speed |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
setFrequency
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setFrequency '{"name":"SPI00", "frequency":9600}'
Response:
{
"returnValue": true
}
spi/setBitJustification
Description
Sets bit justification of the data transferred in the SPI bus i.e MSB-first or LSB-first
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | ID of the SPI interface. |
lsb_first | Required | Boolean | Bit Justification for the data transfer (true = LSB-first, false* = MSB-first) |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
setBitJustification
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setBitJustification '{"name":"SPI00", "lsb_first": false}'
Response:
{
"returnValue": true
}
spi/setBitsPerWord
Description
Configures the number of bits in each SPI transfer word.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | ID of the SPI interface. |
nbits | Required | Number | Setting up bit PerWord. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
setBitsPerWord
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setBitsPerWord '{"name":"SPI00", "nbits":8}'
Response:
{
"returnValue": true
}
spi/setDelay
Description
Sets the delay after a transfer before the chip select status is changed and the next transfer is triggered.
Parameters
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | ID of the SPI interface. |
delay_usecs | Required | Number | Delay time in micro seconds. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | The status of the operation. Possible values are:
|
Example
setDelay
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setDelay '{"name":"SPI00", "delay_usecs":0}'
Response:
{
"returnValue": true
}
spi/close
Description
Closes the opened SPI bus, for other applications to use.
Parameters
None
Call Returns
Name | Required | Type | Description |
---|---|---|---|
errorText | Optional | String | The reason for the failure of the operation. See the API Error Codes Reference section for details. |
errorCode | Optional | Number | The error code for the failed operation. |
returnValue | Required | Boolean | Indicates the status of operation. Possible values are: |
Example
close
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/close '{"name":"SPI00"}'
Response:
{
"returnValue": true
}
Objects
gpioList
Provides the list of available GPIO pins with the status.
Name | Required | Type | Description |
---|---|---|---|
pin | Required | String | ID of the pin as maintained by the service. |
status | Required | String | Status of the pin as to whether "available" or "used" by other applications |
uartList
Provide List of UART interfaces along with the status
Name | Required | Type | Description |
---|---|---|---|
status | Required | String | Status of the interface. Possible values are:
|
interfaceId | Required | String | Interface ID as maintained by the service. |
config
Configurations to be set for the opened UART Interface.
Name | Required | Type | Description |
---|---|---|---|
canonical | Optional | Boolean | Enable or disable canonical mode for the opened UART interface. |
i2cBusList
List of I2C buses and the slave address.
Name | Required | Type | Description |
---|---|---|---|
slaveAddress | Optional | String array | Address of I2C slaves. |
name | Optional | String | I2C bus name. |
API Error Codes Reference
Error Code | Error Text | Error Description |
---|---|---|
-994 | kEREMOTEIO | Remote IO error. |
-997 | EBUSY | Pin is being accessed by other applications. |
-995 | kEPERM | Permission to access the pin is denied. |
-996 | ENODEV | File system was not mounted. |
-993 | kEINVAL | Invalid argument. |