Note
This API has been available since API level 13.
This API has been available since API level 13.
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.
NA
API level 13
Closes the opened GPIO pin, so that the pin is available for other applications to use.
Name | Required | Type | Description |
---|---|---|---|
pin | Required | String | ID of the pin. |
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 Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/close '{"pin":"gpio4"}'
Response:
{
"returnValue": true
}
API level 13
Returns the direction of the required GPIO pin.
Name | Required | Type | Description |
---|---|---|---|
pin | Required | String | ID of the pin. |
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 scenario
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/getDirection '{"pin":"gpio4"}'
Response:
{
"returnValue": true,
"direction": "out"
}
API level 13
Returns the file descriptor for the GPIO pin specified in the input.
Name | Required | Type | Description |
---|---|---|---|
id | Required | String | ID of the pin. |
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 Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/getPollingFd '{"id" : "gpio4"}'
Response:
{
"fd": 8,
"returnValue": true
}
API level 13
Reads the value of the opened input pin
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 |
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 Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/getValue '{"pin":"gpio4"}'
Response:
{
"subscribed": false,
"returnValue": true,
"value": "low"
}
API level 13
Provides the list of available GPIO pins in the target hardware.
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 |
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 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"
}
]
}
API level 13
Opens the GPIO pin, if not already opened by other applications.
Name | Required | Type | Description |
---|---|---|---|
pin | Required | String | ID of the pin. |
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 Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/open ' {"pin":"gpio4"}'
Response:
{
"returnValue": true
}
API level 13
Sets the direction of the GPIO pin to input or output
Name | Required | Type | Description |
---|---|---|---|
pin | Required | String | ID of the pin. |
direction | Required | String | Direction of the pin. Possible values are: "in", "outLow", "outHigh" |
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 Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/setDirection ' {"pin":"gpio4", "direction":"outHigh"}'
Response:
{
"returnValue": true
}
API level 13
Sets the value of the opened output pin to "low" or "high"
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". |
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 Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/setValue ' {"pin":"gpio4", "value":"low"}'
Response:
{
"returnValue": true
}
API level 13
Closes the opened I2C device connected to the bus.
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. |
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 scenario
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/close '{"name":"I2C1", "address":104}'
Response:
{
"returnValue": true
}
API level 13
Returns the file descriptor for the I2c if specified in the input.
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C pin. |
address | Required | Number | Address of the I2C device connected to the interface. |
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. |
/i2c/getPollingFd
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/getPollingFd '{"name" : "I2C1", "address" :104}'
Response:
{
"fd": 10,
"returnValue": true
}
API level 13
Provides the list of available I2C buses.
Name | Required | Type | Description |
---|---|---|---|
verbose | Optional | Boolean | Provide a list of I2C buses with slaveAddress and more details. |
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 : 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"
}
]
}
API level 13
Opens the device connected to I2C bus.
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 |
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:
|
open
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/open '{"name":"I2C1", "address":104}'
Response:
{
"returnValue": true
}
API level 13
Reads data from the I2C device.
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Name of the I2C device. |
address | Required | String | Address of the device that is being used. |
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. |
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
}
API level 13
Reads a value from the register buffer.
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. |
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. |
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
}
API level 13
Reads a byte from a given register of the I2C device.
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. |
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. |
readRegByte
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/readRegByte '{"name":"I2C1","address":104, "reg":0}'
Response:
{
"data": 22,
"returnValue": true
}
API level 13
Reads a word from the register of the i2c device.
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. |
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 scenario
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/readRegWord '{"name":"I2C1","address":104, "reg":0}'
Response:
{
"data": 1111,
"returnValue": true
}
API level 13
Writes the data to the opened I2C device.
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. |
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. |
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
}
API level 13
Writes data to the register buffer of the connected I2C device.
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. |
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. |
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
}
API level 13
Writes a byte from a given register.
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. |
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:
|
writeRegByte
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/writeRegByte '{"name":"I2C1", "address":104, "reg":0, "data":22}'
Response:
{
"returnValue": true
}
API level 13
Writes a word to the register of the I2C device.
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. |
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:
|
writeRegWord
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/writeRegWord '{"name":"I2C1","address":104, "reg":0, "data":1111}'
Response:
{
"returnValue": true
}
API level 13
Closes the opened SPI bus, for other applications to use.
None
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: |
close
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/close '{"name":"SPI00"}'
Response:
{
"returnValue": true
}
API level 13
Provides the list of available SPI buses in the target hardware.
None
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:
|
list
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/list '{}'
Response:
{
"returnValue": true,
"list": [
"SPI00"
]
}
API level 13
Opens the SPI bus, if not already opened by other applications.
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | ID of the SPI bus interface. |
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:
|
open
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/open '{"name" :"SPI00"}'
Response:
{
"returnValue": true
}
API level 13
Sets bit justification of the data transferred in the SPI bus i.e MSB-first or LSB-first
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) |
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:
|
setBitJustification
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setBitJustification '{"name":"SPI00", "lsb_first": false}'
Response:
{
"returnValue": true
}
API level 13
Configures the number of bits in each SPI transfer word.
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | ID of the SPI interface. |
nbits | Required | Number | Setting up bit PerWord. |
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:
|
setBitsPerWord
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setBitsPerWord '{"name":"SPI00", "nbits":8}'
Response:
{
"returnValue": true
}
API level 13
Sets the delay after a transfer before the chip select status is changed and the next transfer is triggered.
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | ID of the SPI interface. |
delay_usecs | Required | Number | Delay time in micro seconds. |
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:
|
setDelay
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setDelay '{"name":"SPI00", "delay_usecs":0}'
Response:
{
"returnValue": true
}
API level 13
Sets the rate of data transfer (Hz)
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 |
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:
|
setFrequency
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setFrequency '{"name":"SPI00", "frequency":9600}'
Response:
{
"returnValue": true
}
API level 13
Sets modes that correspond to the possible clocking configurations.
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). |
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:
|
setMode
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setMode '{"name":"SPI00", "mode":0}'
Response:
{
"returnValue": true
}
API level 13
Opens a connection for receiving/transmitting data to/from a particular slave device.
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. |
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. |
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
]
}
API level 13
Writes a chunk of data to SPI device.
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. |
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. |
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
}
API level 13
Writes a byte of data to the SPI device connected to the bus.
Name | Required | Type | Description |
---|---|---|---|
data | Required | Number | Data to be written. |
name | Required | String | ID of the SPI interface. |
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:
|
writeByte
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/writeByte '{"name":"SPI00", "data":10}'
Response:
{
"returnValue": true
}
API level 13
Closes the opened UART device so that the interface is available for other apps to use.
Name | Required | Type | Description |
---|---|---|---|
interfaceId | Required | String | ID of the UART interface. |
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 Code
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/close '{"interfaceId":"UART1"}'
Response:
{
"returnValue": true
}
API level 13
Reads the baud rate of the opened UART device.
Name | Required | Type | Description |
---|---|---|---|
interfaceId | Required | String | ID of the UART interface. |
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. |
getBaudrate
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/getBaudrate '{"interfaceId":"UART1"}'
Response:
{
"returnValue": true,
"baudrate": 9600
}
API level 13
Returns the file descriptor for the UART interface specified in the input.
Name | Required | Type | Description |
---|---|---|---|
id | Required | String | ID of the UART interface. |
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. |
getPollingFd
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/getPollingFd '{"id" : "UART1"}'
Response:
{
"fd": 7,
"returnValue": true
}
API level 13
Provides the list of available UART interfaces in the target hardware.
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 |
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 without Subscription
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/list '{}'
Response:
{
"subscribed":false,
"returnValue":true,
"uartList":[
{
"status":"used",
"interfaceId":"UART1"
}
]
}
API level 13
Opens the UART interface, if not already opened by other applications.
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. |
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 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
}
API level 13
Reads the data from the opened UART device.
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. |
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 : 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"
}
API level 13
Sets the baud rate of the opened UART device to the required value.
Name | Required | Type | Description |
---|---|---|---|
interfaceId | Required | String | ID of the UART interface. |
baudrate | Required | Number | Value of the baud rate. |
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:
|
setBaudrate
# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/setBaudrate '{"interfaceId":"UART1", "baudrate":9600}'
Response:
{
"returnValue": true
}
API level 13
Writes the data to the opened UART device.
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. |
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 : 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
}
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. |
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 |
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. |
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. |
Error Code | Error Text | Error Description |
---|---|---|
-997 | EBUSY | Pin is being accessed by other applications. |
-996 | ENODEV | File system was not mounted. |
-995 | kEPERM | Permission to access the pin is denied. |
-994 | kEREMOTEIO | Remote IO error. |
-993 | kEINVAL | Invalid argument. |
Contents