Implementace rezimu kontroler.
[lptgpib.git] / device.c
1 #include "lptgpib.h"
2 #include <string.h> /* strlen */
3
4 #define ADDRESS 6
5 int main(int argc, char **argv){
6         lptgpib_init(0x378);
7         
8         char buf[1024] = "Welcome to echo device!\n"
9                          "I will remember and reply with string written to me.";
10         int len = strlen(buf);
11         while (1) {
12                 char val, flags;
13                 val = lptgpib_read_byte(&flags);
14                 if ((flags & ATN) && (val == MTA + ADDRESS))
15                         lptgpib_write_data(buf, len);
16                 if ((flags & ATN) && (val == MLA + ADDRESS))
17                         len = lptgpib_read_data(buf, sizeof(buf));
18         }
19 }