]> rtime.felk.cvut.cz Git - fpga/rpi-motor-control-pxmc.git/blob - src/libs4c/cmdproc/cmdio_std.c
Raspberry Pi 3-phase motor control educational system based on PXMC.
[fpga/rpi-motor-control-pxmc.git] / src / libs4c / cmdproc / cmdio_std.c
1 /* Definitions of IOs */
2 #include <unistd.h> 
3 #include <cmd_proc.h>
4 #include <stdio.h>
5
6 static int std_putc(cmd_io_t *cmd_io, int ch) { 
7     int r=putchar(ch);
8     fflush(stdout);
9     return r;
10 }
11
12 //int _getkey_nb(void);
13 static int std_getc(cmd_io_t *cmd_io) { 
14     return getchar();           /* On UNIX, we don't use non-blocking
15                                  * variant. */
16     //return _getkey_nb();
17 }
18 static int std_write(cmd_io_t *cmd_io, const void *buf, int count) {
19     return write(1, buf, count);
20 }
21 static int std_read(cmd_io_t *cmd_io, void *buf, int count) {
22     return read(0, buf, count); 
23 }
24
25 cmd_io_t cmd_io_std={
26     putc:std_putc,
27     getc:std_getc,
28     write:std_write,
29     read:std_read
30 };
31