[英]How to use a read() function or similars on ARM application to Verifone Device with Verix OS
I am trying to make my first code to a Verifone Device. 我正在尝试将我的第一个代码添加到Verifone设备。 This device has Verix OS and Arm Processor.
该设备具有Verix OS和Arm Processor。 I was following the "OPERATING SYSTEM PROGRAMMING TOOLS REFERENCE MANUAL" and its code works well:
我遵循的是“操作系统编程工具参考手册”,其代码运行良好:
#include <string.h>
#include <svc.h>
char Greeting[] = "Hello!";
void main (void)
{
int display = open(DEV_CONSOLE, O_WRONLY);
write(display, Greeting, strlen(Greeting));
normal_tone();
close(display);
}
however, my code does'nt work well. 但是,我的代码无法正常运行。 Why?
为什么? This and other variations compile, but the entries by keypad does not work.
可以编译此版本和其他版本,但是按键盘输入不起作用。
#include <string.h>
#include <svc.h>
#include <stdio.h>
int main (void)
{
int display = open(DEV_CONSOLE, O_RDWR);
char result[30];
char ent[2]="\0\0";
write(display, "\nEnter a number: ", 17);
read(display, ent, 1);
sprintf(result,"\nPressed key: %s", ent);
write(display, result, strlen(result));
normal_tone();
close(display);
return 0;
}
I have already tried scanf(), fscanf(), getchar(), fgetc(), fgets()... Always happens similars things. 我已经尝试过scanf(),fscanf(),getchar(),fgetc(),fgets()...总是发生类似的事情。 Write() and similars sometimes works sometimes not, it depends on the combination with read(), Scanf()...but the read() function and similars never worked on my Verifone device.
Write()和类似方法有时有时无法工作,这取决于与read(),Scanf()的组合...但是read()函数和类似方法在我的Verifone设备上从未起作用。
int display = open(DEV_CONSOLE, O_WRONLY);
O_WRONLY
means write only . O_WRONLY
表示只写 。 Try using O_RDWR
instead: 尝试改用
O_RDWR
:
int display = open(DEV_CONSOLE, O_RDWR);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.