groupcacheread.c
1 /* 2 EIB Demo program 3 Copyright (C) 2005-2011 Martin Koegler <mkoegler@auto.tuwien.ac.at> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 #include "common.h" 20 21 int 22 main (int ac, char *ag[]) 23 { 24 int len; 25 EIBConnection *con; 26 eibaddr_t dest; 27 eibaddr_t src; 28 uint8_t buf[200]; 29 30 if (ac != 3) 31 die ("usage: %s url eibaddr", ag[0]); 32 con = EIBSocketURL (ag[1]); 33 if (!con) 34 die ("Open failed"); 35 dest = readgaddr (ag[2]); 36 37 len = EIB_Cache_Read (con, dest, &src, sizeof(buf), buf); 38 if (len == -1) 39 die ("Read failed"); 40 41 switch (buf[1] & 0xC0) 42 { 43 case 0x40: 44 printf ("Response"); 45 break; 46 case 0x80: 47 printf ("Write"); 48 break; 49 } 50 printf (" from "); 51 printIndividual (src); 52 if (buf[1] & 0xC0) 53 { 54 printf (": "); 55 if (len == 2) 56 printf ("%02X", buf[1] & 0x3F); 57 else 58 printHex (len - 2, buf + 2); 59 } 60 printf ("\n"); 61 62 EIBClose (con); 63 return 0; 64 }