- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在研究 aeroflex gaisler 硬件(RTEMS 操作系统和 leon2 处理器)与桌面终端之间的通信接口(interface) (RS232)。我写了一个代码用于它们之间的通信。我在所有函数调用中都遇到错误,如果有人遇到过此类问题,请帮助我修复它。
注意:此错误与我之前的问题不同。
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <ioctl.h>
#include <apbuart.h>
#include <rtems.h>
#include <drvmgr/drvmgr.h>
#ifndef serial_h
#define serial_h
#include "serial-com.h"
#endif
//#ifndef read_serial_h
// #define read_serial_h
// #include "read-serial.h"
//#endif
#ifndef memory_h
#define memory_h
#include "memory.h"
#endif
#define BUFSIZE 500
void readSerialPort(char portname, char tbuffer[8])
{
char fd;
// create a new handle for the serial com port
fd = createSerialPort("portname", DWORD accessdirection); // function call
// set the configuration of the handle
setComPortConfig(fd);
// set the timeout configuration of the handle
setComPortTimeouts(fd);
char TBuffer[BUFSIZE];
sprintf(TBuffer,"%c",tbuffer);
char nread = strlen(TBuffer);
readFromSerialPort(fd, TBuffer, nread);
// read from terminal.
// // create a new char buffer
// //char outputBuffer[BUFSIZE];
// int h1, h2, h3 ;
//
//
// // copy the two value in the outputbuffer
// // the ";" is used a delimiter
// // copy the two value in the outputbuffer
// // the ";" is used a delimiter
// sscanf(EF->a,"%d\n",&h1);
// sscanf(EF->b,"%d",&h2);
// sscanf(EF->c,"%d\n",&h3);
//
// // compute the actual size of the output string
// int nread1 = strlen(EF->a);
// int nread2 = strlen(EF->b);
// int nread3 = strlen(EF->c);
// write the outputBuffer to the serial com port
// readFromSerialPort(hSerial, EF->a, nread1);
// readFromSerialPort(hSerial, EF->b, nread2);
// readFromSerialPort(hSerial, EF->c, nread3);
// close the handle
CloseHandle(fd);
}
函数体:
char createSerialPort("portname", DWORD accessdirection)
{
// HANDLE hSerial = CreateFile(portname,
// accessdirection,
// 0,
// 0,
// OPEN_EXISTING,
// 0,
// 0);
char fd = CreateFile("/dev/rastaio0/apbuart1", GENERIC_READ | GENERIC_WRITE); // create = open
if (fd == INVALID_HANDLE_VALUE) {
//call GetLastError(); to gain more information
}
return hSerial;
}
错误如: DWORD 未初始化 一般阅读 | GENERIC_WRITE 未初始化 访问方向未初始化
我对函数调用和函数体有疑问。给我一些想法。
最佳答案
改变
void readSerialPort(char portname, char tbuffer[8])
到 void readSerialPort(char portname, char *tbuffer)
char createSerialPort("portname", DWORD accessdirection)
到 char createSerialPort(char *portname, DWORD accessdirection)
fd = createSerialPort("portname", DWORD accessdirection);
改为
fd = createSerialPort("/dev/rastaio0/apbuart1", GENERIC_READ | GENERIC_WRITE);
然后
char fd = CreateFile("/dev/rastaio0/apbuart1", GENERIC_READ | GENERIC_WRITE);
到
char fd = CreateFile(portname, accessdirection);
这将修复您的一些错误。问候,卢卡
关于c - 帮我找出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16896080/
嗨,我是第一次玩 Pig,我很好奇如何处理将一个字段拆分成多个其他字段。 我有一个包,A,如下图: grunt> Dump A; (text, text, Mon Mar 07 12:00:00 CD
如何添加架构中未定义的固定字段(例如日期或月份)?我运行了以下 pig 脚本以将固定日期添加到我的结果表中,并收到以下错误消息:Invalid field projection。方案中不存在投影字段
我是一名优秀的程序员,十分优秀!