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

subscribeOptionalBoolean

Indicates if subscribed to get notified when there is a change in available pins. Possible values are:

  • true: Subscribed for notifications.
  • false: Not subscribed.

Default: false

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

subscribedOptionalBoolean

Indicates if subscribed to get notifications. Possible values are:

  • true: Subscribed for notifications.
  • false: Not subscribed.
gpioListOptionalObject array: gpioList

List of available GPIO pins with the status.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

pinRequiredString

ID of the pin.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

pinRequiredString

ID of the pin.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
directionOptionalString

Indicates the direction of the pin.

Example

# 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

pinRequiredString

ID of the pin.

directionRequiredString

Direction of the pin. Possible values are: "in", "outLow", "outHigh"

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

idRequiredString

ID of the pin.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
fdOptionalString

File descriptor of the interface.

Example

# 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

pinRequiredString

ID of the pin.

subscribeOptionalBoolean

Indicates if subscribed to get notified when there is a change in value. Possible values are:

  • true: Subscribed for notifications.
  • false: Not subscribed.

Default: false

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

subscribedOptionalBoolean

Indicates if subscribed to get notifications. Possible values are:

  • true: Subscribed for notifications.
  • false: Not subscribed.
valueOptionalString

Indicates the value. Possible values are: "low" or "high".

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

pinRequiredString

ID of the pin.

valueRequiredString

Value of the output pin. Possible values are: "low" or "high".

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

pinRequiredString

ID of the pin.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

subscribeOptionalBoolean

Indicates if subscribed to get notified when there is a change in available interfaces. Possible values are:

  • true: Subscribed for notifications.
  • false: Not subscribed.

Default: false

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

subscribedOptionalString

Indicates if subscribed to get notifications. Possible values are:

  • true: Subscribed for notifications.
  • false: Not subscribed.
uartListOptionalObject array: uartList

List of available UART interfaces.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

interfaceIdRequiredString

ID of the UART interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/open '{"interfaceId":"UART1"}'

Response:

{
    "returnValue": true
}

uart/getBaudrate

Description

Reads the baud rate of the opened UART device.

Parameters

Name

Required

Type

Description

interfaceIdRequiredString

ID of the UART interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
baudrateOptionalNumber

Value of the baud rate.

Example

# 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

interfaceIdRequiredString

ID of the UART interface.

baudrateRequiredNumber

Value of the baud rate.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalString

The error code for the failed operation.

returnValueRequiredString

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

idRequiredString

ID of the UART interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
fdOptionalString

File descriptor of the interface.

Example

# 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

interfaceIdRequiredString

ID of the UART interface.

sizeOptionalNumber

Size of the data to be read. If not specified, all available data is read.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
dataOptionalString

Value read from the opened UART interface.

dataTypeOptionalString

Type of data in the data field.

bytes_readRequiredNumber

Size of the read data.

Example

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/read '{"interfaceId":"UART1","size":9}'

Response:

{
   "bytes_read":0,
   "returnValue":true,
   "data":[
      
   ],
   "dataType":""
}

uart/write

Description

Writes the data to the opened UART device.

Parameters

Name

Required

Type

Description

interfaceIdRequiredString

ID of the UART interface.

dataRequiredString

Data to write into the UART device.

dataTypeRequiredString

Type of data in the data field.

sizeOptionalString

Size of the data passed to be written.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
sizeOptionalNumber

Size of the data written to the device.

Example

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/write '{"interfaceId":"UART1", "data": ['1','2','3','4','5','6','7','8','9'], "dataType":"string" , "size":9}'

Response:

{
    "returnValue": true,
    "size": 0
}

uart/close

Description

Closes the opened UART device so that the interface is available for other apps to use.

Parameters

Name

Required

Type

Description

interfaceIdRequiredString

ID of the UART interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

None

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
i2cListOptionalString array

List of I2C buses.

Example

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/list '{}'

Response:

{
    "returnValue": true,
    "i2cBusList": [
        "I2C1"
    ]
}

i2c/open

Description

Opens the device connected to I2C bus.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device to be opened, which is connected to the I2C bus

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

nameRequiredString

Name of the I2C device.

addressRequiredString

Address of the device that is being used.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
sizeOptionalNumber

Size of the data read.

dataOptionalObject array

Data read from the device.

Example

# 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

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

regRequiredNumber

Register address.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
dataOptionalNumber

Read value from the register.

Example

# 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

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

regRequiredNumber

Register address.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
dataOptionalNumber

Read value from the register.

Example

# 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

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

regRequiredNumber

Register address.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
dataOptionalObject array

Data read.

Example

# 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

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

dataRequiredObject array

Data to be written.

sizeOptionalNumber

Size of data to be written.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
sizeOptionalNumber

Bytes written.

Example

# 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

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

regRequiredNumber

Register address.

dataRequiredNumber

Data to write into register.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredNumber

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

regRequiredNumber

Register address.

dataRequiredNumber

Data to write into register.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

regRequiredNumber

Register address.

dataRequiredObject array

Data that needs to be written.

sizeRequiredNumber

Size of the data.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
sizeRequiredNumber

Bytes to be written into register.

Example

# 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

nameRequiredString

Name of the I2C pin.

addressRequiredNumber

Address of the I2C device connected to the interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

Indicates the status of operation.Possible values are:
true - Indicates that the operation was successful.
false - Indicates that the operation failed.

fdOptionalString

File descriptor of the interface.

Example

# 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

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device to be closed, which is connected to the I2C bus.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

listOptionalString array

List of available SPI buses.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

nameRequiredString

ID of the SPI bus interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

nameRequiredString

ID of the SPI interface.

modeRequiredNumber

Mode to be set for the SPI device (possible values: 0 to 3).

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

dataRequiredNumber

Data to be written.

nameRequiredString

ID of the SPI interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

nameRequiredString

ID of the SPI interface.

dataRequiredObject array

Data to be written to the SPI device.

sizeRequiredNumber

Size of the data.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
sizeOptionalNumber

Size of the data written to the device.

Example

# 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

nameRequiredString

ID of the SPI interface.

dataOptionalObject array

Data to be transferred to the SPI device.

sizeRequiredNumber

Size of the data to be written/read, if data field is not present.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
tx_sizeOptionalNumber

Size of the data transferred to the SPI device.

rx_sizeOptionalNumber

Size of the data read from the SPI device.

rx_dataOptionalObject array

Receiving of the data from slave.

Example

# 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

nameRequiredString

ID of the SPI interface.

frequencyRequiredNumber

Setting the frequency of the bus upto value that is allowed based on the bus max speed

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

nameRequiredString

ID of the SPI interface.

lsb_firstRequiredBoolean

Bit Justification for the data transfer (true = LSB-first, false* = MSB-first)

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

nameRequiredString

ID of the SPI interface.

nbitsRequiredNumber

Setting up bit PerWord.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

nameRequiredString

ID of the SPI interface.

delay_usecsRequiredNumber

Delay time in micro seconds.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

# 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

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:
true - Indicates that the operation was successful.
false - Indicates that the operation failed.

Example

# 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

pinRequiredString

ID of the pin as maintained by the service.

statusRequiredString

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

statusRequiredString

Status of the interface.

Possible values are:

  • used - The interface is currently being used.
  • available - The interface is available for the app to use
interfaceIdRequiredString

Interface ID as maintained by the service.

API Error Codes Reference

Error Code

Error Text

Error Description

-994kEREMOTEIO

Remote IO error.

-997EBUSY

Pin is being accessed by other applications.

-995kEPERM

Permission to access the pin is denied.

-996ENODEV

File system was not mounted.

-993kEINVAL

Invalid argument.

Contents