简体   繁体   中英

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. This device has Verix OS and 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. 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.

int display = open(DEV_CONSOLE, O_WRONLY);

O_WRONLY means write only . Try using O_RDWR instead:

int display = open(DEV_CONSOLE, O_RDWR);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM