Search

EC100 ARM Industrial Computer – Development Guide

Development Preparation

  1. SSH Tools

We recommend using MobaXterm, or you can choose your preferred SSH tool.

https://iotrouter.yuque.com/attachments/yuque/0/2025/zip/40387797/1751447985727-10cb8014-e57d-4f95-85f2-722b2f822d6f.zip

2. Serial port debugging tool

We recommend using XCOM, or choose your preferred serial port debugging tool

https://iotrouter.yuque.com/attachments/yuque/0/2025/zip/40387797/1751448098345-cc351ada-aa82-4de7-b0bf-b6a909e637bc.zip

3. Hardware Tools

Common debugging tools include: CAN-to-USB tools / 485-to-USB tools / network cables, etc. Please prepare these on your own.

4. Cross-Compilation Toolchain

https://iotrouter.yuque.com/attachments/yuque/0/2025/tar/40387797/1751447691686-3001e3bf-2f16-43d3-a4d7-55c4705dff97.tar

Software Environment

OS: Ubuntu 20.04.1; partially cropped

NodeJs: v22.16.0

Python: python3.8

Shell: bash

GLIBC: 2.31

Peripheral Interfaces

1. Serial Port

The EC100 comes with two built-in RS485 transceivers.

Note: With RS485 transmission and reception, users do not need to worry about switching between transmission and reception, as the hardware will handle it automatically.

1.1. Quick test

Use the minicom tool for testing. For specific usage instructions, please search Baidu or consult DeepSeek.

1.2. Code test example

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <unistd.h>

#include <fcntl.h>

#include <termios.h>

#include <errno.h>

#include <sys/select.h>

#define BUFFER_SIZE 256

typedef struct {

int baud_rate; // Baud rate

int data_bits; // Data bits (5,6,7,8)

int stop_bits; // Stop bits (1,2)

char parity; // Parity bit (N: No parity, O: Odd parity, E: Even parity)

} SerialConfig;

int set_serial_attr(int fd, SerialConfig *config)

{

struct termios tty;

if (tcgetattr(fd, &tty) < 0) {

perror(“tcgetattr”);

return -1;

}

// Set baud rate

speed_t speed;

switch (config->baud_rate) {

case 9600:   speed = B9600; break;

case 19200:  speed = B19200; break;

case 38400:  speed = B38400; break;

case 57600:  speed = B57600; break;

case 115200: speed = B115200; break;

default:

fprintf(stderr, “Unsupported baud rate, using 115200\n”);

speed = B115200;

}

cfsetispeed(&tty, speed);

cfsetospeed(&tty, speed);

// Set data bits

tty.c_cflag &= ~CSIZE;

switch (config->data_bits) {

case 5: tty.c_cflag |= CS5; break;

case 6: tty.c_cflag |= CS6; break;

case 7: tty.c_cflag |= CS7; break;

case 8: tty.c_cflag |= CS8; break;

default:

fprintf(stderr, “Unsupported data bits, using 8\n”);

tty.c_cflag |= CS8;

}

// Set stop bit

if (config->stop_bits == 2) {

tty.c_cflag |= CSTOPB;

} else {

tty.c_cflag &= ~CSTOPB;

}

// Set the check digit

switch (config->parity) {

case ‘N’: case ‘n’:

tty.c_cflag &= ~PARENB; // No verification

break;

case ‘O’: case ‘o’:

tty.c_cflag |= PARENB;  // Odd parity check

tty.c_cflag |= PARODD;

break;

case ‘E’: case ‘e’:

tty.c_cflag |= PARENB;  // Parity check

tty.c_cflag &= ~PARODD;

break;

default:

fprintf(stderr, “Unsupported parity, using N\n”);

tty.c_cflag &= ~PARENB;

}

// Other settings

tty.c_cflag |= (CLOCAL | CREAD);  // Enable receive and local mode

tty.c_cflag &= ~CRTSCTS;        // No hardware flow control

tty.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // Original input mode

tty.c_oflag &= ~OPOST;            // Original output mode

tty.c_cc[VMIN] = 1;                // Minimum number of characters read

tty.c_cc[VTIME] = 0;            // Read timeout (unit: 0.1 seconds)

if (tcsetattr(fd, TCSANOW, &tty) < 0) {

perror(“tcsetattr”);

return -1;

}

return 0;

}

int main(int argc, char *argv[])

{

int fd;

char *portname;

if (argc < 2) {

fprintf(stderr, “Usage: %s <serial_port>\n”, argv[0]);

exit(EXIT_FAILURE);

}

portname = argv[1];

// Configure serial port parameters

SerialConfig config = {

.baud_rate = 115200,  // 波特率

.data_bits = 8,       // 数据位

.stop_bits = 1,       // 停止位

.parity = ‘N’         // 校验位 (N:无校验, O:奇校验, E:偶校验)

};

fd = open(portname, O_RDWR | O_NOCTTY | O_NONBLOCK);

if (fd < 0) {

perror(“open”);

exit(EXIT_FAILURE);

}

if (set_serial_attr(fd, &config)) {

close(fd);

exit(EXIT_FAILURE);

}

printf(“Serial port echo test running on %s\n”, portname);

printf(“Configuration: %d baud, %d data bits, %d stop bit, %c parity\n”,

config.baud_rate, config.data_bits, config.stop_bits, config.parity);

printf(“Press Ctrl+C to exit.\n”);

fd_set readfds;

char buffer[BUFFER_SIZE];

int n;

while (1) {

FD_ZERO(&readfds);

FD_SET(fd, &readfds);

// 无限等待数据到达(移除了超时设置)

if (select(fd + 1, &readfds, NULL, NULL, NULL) < 0) {

perror(“select”);

break;

}

if (FD_ISSET(fd, &readfds)) {

n = read(fd, buffer, BUFFER_SIZE – 1);

if (n > 0) {

buffer[n] = ‘\0’;

printf(“Received %d bytes: %s\n”, n, buffer);

// 回显数据

write(fd, buffer, n);

} else if (n < 0) {

if (errno != EAGAIN && errno != EWOULDBLOCK) {

perror(“read”);

break;

}

}

}

}

close(fd);

return 0;

}

 

Recent Articles

Contact Us