Linux - HPE Edgeline EL300 Getting Started Manual

Converged edge system daughter card
Table of Contents

Advertisement

}
if (inBuffer[2] == 0x08)
{
}
}
NOTE: When sending the 0xB1 command (Request to Reset Device), it will cause the COM port
number to change to a different port number supplied by Windows. This causes all the hard-coded
port numbers to be incorrect. Please check the COM port number after each reset.

Linux

C Language Example
When using the C language in Linux, the HPE CAN bus serial port is opened and written to as a file. The
termios structure is used to set up the serial port.
When using the Read SW Version command, bytes will demonstrate how to view and edit the serial port.
The various other commands and responses are explained in Appendix A of this document.
The following code block explains how to open the serial port using the device path:
char* fileName="/dev/ttyACM0";
int fd = -1;
fd = open(fileName,O_RDWR | O_NOCTTY | O_SYNC);
if (-1 == fd)
{
printf("Open failed\n");
}
The following code block explains how to set up the serial port:
struct termios SerialPortSettings;
memset(&SerialPortSettings, 0, sizeof SerialPortSettings); //clear structure
tcgetattr(fd, &SerialPortSettings);
cfsetispeed(&SerialPortSettings, B115200);
cfsetospeed(&SerialPortSettings, B115200);
SerialPortSettings.c_cflag &= ~PARENB;
SerialPortSettings.c_cflag &= ~CSTOPB;
SerialPortSettings.c_cflag &= ~CSIZE;
SerialPortSettings.c_cflag |= CS8;
SerialPortSettings.c_cflag &= ~CRTSCTS;
SerialPortSettings.c_cflag &= ~(ICANON | ECHO | ECHOE | ISIG); //no canonical, echo, echoe, or signals
SerialPortSettings.c_cflag |= CREAD | CLOCAL;
SerialPortSettings.c_cc[VMIN] = 1;
SerialPortSettings.c_cc[VTIME] = 5;
cfmakeraw(&SerialPortSettings);
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &SerialPortSettings);
The following code block explains how to use the Read SW Version command to edit the serial port.
char GetVersionCommand[] = {0xFF,0x00,0xC0};
size_t bytesToWrite = 3;
int wlen = write(fd, GetVersionCommand, bytesToWrite);
if (-1 == wlen)
{
printf("ERROR - error is: %d\n", errno);
}
//channel 1
//get message length
2x CAN Bus A/B/FD 2.0 - Glavanically Isolated Daughter Card
//declare termios structure
//read current attributes
//set input speed
//set output speed
//not using parity bit
//not using stop bits
//clear all sizes
//set 8 bit byte
//no HW flow control
//enable receiver and ignore modem control
//set min chars to 1
//set timeout to 5 deciseconds
//set RAW mode
//flush input
//set the attributes
11

Advertisement

Table of Contents
loading

Table of Contents