0

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.

Geovane
  • 1
  • 1

1 Answers1

0
int display = open(DEV_CONSOLE, O_WRONLY);

O_WRONLY means write only. Try using O_RDWR instead:

int display = open(DEV_CONSOLE, O_RDWR);
Tim
  • 4,790
  • 4
  • 33
  • 41
  • Nice! I didn't know about that, but it didn't work too. – Geovane Mar 20 '18 at 00:14
  • Can you elaborate on what didn't work? Are there error messages? What are the return values of the functions you are calling? – Tim Mar 20 '18 at 16:13
  • Read() function is skiped. the console returns only: Enter a number: Pressed key: The applications doesn't ask for entry. – Geovane Mar 20 '18 at 16:54