Moxa UC-8416-T-LX Инструкция по эксплуатации онлайн [67/90] 170872

Moxa UC-8416-T-LX Инструкция по эксплуатации онлайн [67/90] 170872
UC-8410/8416/8418/8430 Programmer's Guide
5-15
2. If you use stty to get the serial information, you will get a speed equal to 0.
SRAM
1. Introduction
The UC-8410/8416/8418/8430/8430 provides 256 KB of embedded SRAM. As there is a system battery
inside the computer, the SRAM can work and be used to keep data even when the system is crashed. This
means that the data stored on the SRAM will not be lost after the UC-8410/8416/8418/8430/8430 is
powered off.
2. How the SRAM works
The SRAM device can be programmed through the file /dev/sram. This means that you can read from or
write to /dev/sram to store data on the embedded SRAM. The following example illustrates how to do this:
/**************************************************************
History :
Versoin Author Date Comment
1.0 Jared Wu. 09-11-2008 Write a pattern to SRAM.
**************************************************************/
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <linux/kd.h>
#define SRAM_SIZE 0x00040000 // 256 Kbytes
static char sram_buf1[SRAM_SIZE], sram_buf2[SRAM_SIZE];
int main(int argc, char * argv[])
{
int fd, len;
unsigned long ms=0;
char pattern=‘9’;
if ( argc > 2 ) {
printf(“Usage: %s [pattern]\n”);
exit(0);
}
if ( argc == 2 ) {
pattern=argv[1][0];
printf(“pattern:%c\n”, pattern);
}
fd = open(“/dev/sram”, O_RDWR);
if( fd < 0 ) {
printf(“Open /dev/sram fail”);
exit(0);
}
// Write the sram with patern
memset(sram_buf1, pattern, sizeof(sram_buf1));
len=write(fd, sram_buf1, sizeof(sram_buf1));
if( len < 0 ) {
printf(“Write /dev/sram fail”);
exit(0);
}
printf(“The content is written\n”);
close(fd);

Содержание

Скачать