« Back to Development - APIs

Remote Serial Device API

What is the Remote Serial Device API?

The Remote Serial Device API enables an application running on the service module to access external RFC 2217 compliant serial devices connected to the serial port of a Cisco IOS router. This API allows applications to support peripherals that connect to serial ports such as GPS locators.

What package must my application depend upon to use this api?

Your application must depend upon the package axp-vserial.<platform><version>.pkg

How would I package my application with this dependency?

When you are creating your command line arguments to run the packaging script pkg_build.sh, you must include the parameter --deps '<dependency package ssid>,<dependency version>'. An example is given below. Be sure to get your dependency package ssid by using the script pkg_info.sh.

--deps '7a013f0e-07cb-4c25-8122-4a0af7704c3b,all'

Do I have to install this dependency package separately onto the AXP module?

No, you can bundle it with your packaged application using the bundling script pkg_bundle.sh

Do I need to configure the ISR or AXP Module for this API to work?

Yes, you need to assure that on the router in the line0/0/0 interface that the transportation mode is set to either 'telnet' or 'all'. In addition you need to add netconf over beep protocol functionality to both components. On the ISR you'll type the commands below. Be sure to replace <port number> with your actual port number. You can also use ACLs to limit communication, but they're not shown here.

config t
sasl profile SASL_PROFILE
mechanism anonymous
netconf beep listener <port number> sasl SASL_PROFILE
netconf max-sessions 16
end
copy run start

On the AXP service module, you can either manually add the netconf over beep protocol or include it in your source code for you application. The manual steps are shown below. The 'ISR IP address' must match the ip of your ISR, and the 'port number' must also match the chosen port number specified in the net conf beep commands on your ISR.

config t
netconf beep initiator <ISR IP address> <port number>
netconf max-sessions 16
end
copy run start

APPLICATIONEXTENSIONPLATFORM:Return to top

How do I locate and bind my application to the serial device?

The process can be done on manually on the service module or by using the CLI Service API. The manual steps are shown below.

On the service module type "show device serial". The device name should be displayed. Then bind this device to your application. For example if the gps device name displayed is "vtty000" to bind this device to your application, myapp, you would enter the commands below.

config t
app-service myapp
bind serial vtty000 gps
end
copy run start

Please provide a source code example of this API.

remoteSerialTest.c
#include <stdio.h>
#include <fcntl.h>

/*
* This simple program opens a file handle to the serial device.
*/
int main(int argc, char* argv[]){
char *dev;
int fd;
printf("starting program\n");
if(argc > 1) {
dev = strdup(argv[1]);
}
else{
dev = strdup("/dev/modem");
}
fd = open (dev, O_RDWR | O_NONBLOCK | O_NOCTTY | O_NDELAY);
printf("file descriptor is %d.\nExiting program\n", fd);
}

How do I compile the source code example?

To compile this 'C' program is very simple. Type:
gcc remoteSerialTest.c -o remoteSerialTest

Where are the library files located in the sdk and Guest OS for language support such as C, C++ and Python?

The files for support of these languages in the sdk are located in the directory axp-sdk.<version>. In the AXP module Guest OS, you'll find files supporting these languages in the /lib directory and child directories below it.

0 Attachments
2225 Views
Average (0 Votes)
The average rating is 0.0 stars out of 5.
Comments