1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
|
#! /bin/sh -e
## 04_newpatch.dpatch by Manuel Estrada Sainz <ranty@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Some files where left out from the upstream tarball.
if [ $# -ne 1 ]; then
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
fi
case "$1" in
-patch) patch -f --no-backup-if-mismatch -p1 < $0;;
-unpatch) patch -f --no-backup-if-mismatch -R -p1 < $0;;
*)
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1;;
esac
exit 0
diff -urNad 03.lirc.tmp/daemons/hw_caraca.c 03.lirc/daemons/hw_caraca.c
--- 03.lirc.tmp/daemons/hw_caraca.c 2003-03-08 19:22:24.000000000 +0100
+++ 03.lirc/daemons/hw_caraca.c 2003-03-08 19:30:39.000000000 +0100
@@ -0,0 +1,139 @@
+/* $Id: hw_caraca.c,v 1.5 2001/12/08 15:07:03 lirc Exp $ */
+
+/****************************************************************************
+ ** hw_caraca.c ***********************************************************
+ ****************************************************************************
+ *
+ * routines for caraca receiver
+ *
+ * Copyright (C) 1999 Christoph Bartelmus <lirc@bartelmus.de>
+ * modified for caraca RC5 receiver by Konrad Riedel <k.riedel@gmx.de>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <limits.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include "hardware.h"
+#include "serial.h"
+#include "ir_remote.h"
+#include "lircd.h"
+#include "hw_caraca.h"
+#include <caraca/caraca_client.h>
+
+
+#define NUMBYTES 34
+#define TIMEOUT 20000
+
+extern struct ir_remote *repeat_remote,*last_remote;
+
+unsigned char msg[NUMBYTES];
+struct timeval start,end,last;
+lirc_t gap,signal_length;
+ir_code pre,code;
+
+struct hardware hw_caraca=
+{
+ NULL, /* default device */
+ -1, /* fd */
+ LIRC_CAN_REC_LIRCCODE, /* features */
+ 0, /* send_mode */
+ LIRC_MODE_LIRCCODE, /* rec_mode */
+ 16, /* code_length */
+ caraca_init, /* init_func */
+ NULL, /* config_func */
+ caraca_deinit, /* deinit_func */
+ NULL, /* send_func */
+ caraca_rec, /* rec_func */
+ caraca_decode /* decode_func */
+ NULL, /* readdata */
+ "caraca"
+};
+
+int caraca_decode(struct ir_remote *remote,
+ ir_code *prep,ir_code *codep,ir_code *postp,
+ int *repeat_flagp,lirc_t *remaining_gapp)
+{
+ *prep=pre;
+ *codep=code;
+ *postp=0;
+
+ gap=0;
+ if(start.tv_sec-last.tv_sec>=2) /* >1 sec */
+ {
+ *repeat_flagp=0;
+ }
+ else
+ {
+ gap=(start.tv_sec-last.tv_sec)*1000000+
+ start.tv_usec-last.tv_usec;
+
+ if(gap<120000)
+ *repeat_flagp=1;
+ else
+ *repeat_flagp=0;
+ }
+
+ *remaining_gapp=0;
+ LOGPRINTF(1,"code: %llx",(unsigned long long) *codep);
+ return(1);
+}
+
+int caraca_init(void)
+{
+ signal_length=hw.code_length*1000000/1200;
+ if ( (hw.fd = caraca_open(PACKAGE)) < 0) {
+ logprintf(LOG_ERR,"could not open lirc");
+ logperror(LOG_ERR,"caraca_init()");
+ return(0);
+ }
+ /*accept IR-Messages (16 : RC5 key code) for all nodes on the bus */
+ if(set_filter(hw.fd,0x400,0x7c0,0) <= 0)
+ {
+ logprintf(LOG_ERR,"could not set filter for IR-Messages");
+ caraca_deinit();
+ return(0);
+ }
+ return(1);
+}
+
+int caraca_deinit(void)
+{
+ close(hw.fd);
+ return(1);
+}
+
+char *caraca_rec(struct ir_remote *remotes)
+{
+ char *m;
+ int i=0,node,ir,t;
+ int repeat, mouse_event;
+
+ last=end;
+ gettimeofday(&start,NULL);
+ i=read(hw.fd,msg,NUMBYTES);
+ gettimeofday(&end,NULL);
+
+ LOGPRINTF(1,"caraca_rec: %s", msg);
+ sscanf(msg,"%d.%d:%d",&node,&t,&ir);
+
+ /* transmit the node address as first byte, so we have
+ * different codes for every transmitting node (for every room
+ * of the house) */
+
+ code=(ir_code) (node << 8) + ir;
+
+ m=decode_all(remotes);
+ return(m);
+}
diff -urNad 03.lirc.tmp/daemons/hw_caraca.h 03.lirc/daemons/hw_caraca.h
--- 03.lirc.tmp/daemons/hw_caraca.h 2003-03-08 19:22:24.000000000 +0100
+++ 03.lirc/daemons/hw_caraca.h 2003-03-08 19:30:39.000000000 +0100
@@ -0,0 +1,25 @@
+/* $Id: hw_caraca.h,v 1.1 2000/08/25 19:21:17 columbus Exp $ */
+
+/****************************************************************************
+ ** hw_caraca.h **********************************************************
+ ****************************************************************************
+ *
+ * routines for caraca receiver
+ *
+ * Copyright (C) 1999 Christoph Bartelmus <lirc@bartelmus.de>
+ * modified for caraca RC5 receiver by Konrad Riedel <k.riedel@gmx.de>
+ */
+
+#ifndef _HW_caraca_H
+#define _HW_caraca_H
+
+#include "drivers/lirc.h"
+
+int caraca_decode(struct ir_remote *remote,
+ ir_code *prep,ir_code *codep,ir_code *postp,
+ int *repeat_flagp,lirc_t *remaining_gapp);
+int caraca_init(void);
+int caraca_deinit(void);
+char *caraca_rec(struct ir_remote *remotes);
+
+#endif
diff -urNad 03.lirc.tmp/daemons/hw_udp.c 03.lirc/daemons/hw_udp.c
--- 03.lirc.tmp/daemons/hw_udp.c 2003-03-08 19:22:24.000000000 +0100
+++ 03.lirc/daemons/hw_udp.c 2003-03-08 19:30:39.000000000 +0100
@@ -0,0 +1,184 @@
+/****************************************************************************
+ ** hw_udp.c ****************************************************************
+ ****************************************************************************
+ *
+ * receive mode2 input via UDP
+ *
+ * Copyright (C) 2002 Jim Paris <jim@jtan.com>
+ *
+ * Distribute under GPL version 2 or later.
+ *
+ * Received UDP packets consist of some number of LE 16-bit integers.
+ * The high bit signifies whether the received signal was high or low;
+ * the low 15 bits specify the number of 1/16384-second intervals the
+ * signal lasted.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/fcntl.h>
+#include <netinet/in.h>
+#include <errno.h>
+#include <stdint.h> /* for uint16_t */
+
+#include "hardware.h"
+#include "ir_remote.h"
+#include "lircd.h"
+#include "receive.h"
+#include "transmit.h"
+#include "hw_default.h"
+
+static int zerofd; /* /dev/zero */
+static int sockfd; /* the socket */
+
+int udp_init()
+{
+ int port;
+ struct sockaddr_in addr;
+
+ logprintf(LOG_INFO,"Initializing UDP",hw.device);
+
+ init_rec_buffer();
+
+ port=atoi(hw.device);
+ if(port==0) {
+ logprintf(LOG_ERR,"invalid port: %s",hw.device);
+ return 0;
+ }
+
+ /* hw.fd needs to point somewhere when we have extra data */
+ if((zerofd=open("/dev/zero",O_RDONLY))<0) {
+ logprintf(LOG_ERR,"can't open /dev/zero: %s",
+ strerror(errno));
+ return 0;
+ }
+
+ if((sockfd=socket(AF_INET,SOCK_DGRAM,0))<0) {
+ logprintf(LOG_ERR,"error creating socket: %s",
+ strerror(errno));
+ close(zerofd);
+ return 0;
+ }
+
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ addr.sin_port = htons(port);
+
+ if(bind(sockfd,(struct sockaddr *)&addr,sizeof(addr))<0) {
+ logprintf(LOG_ERR,"can't bind socket to port %d: %s",
+ port,strerror(errno));
+ close(sockfd);
+ close(zerofd);
+ return 0;
+ }
+
+ logprintf(LOG_INFO,"Listening on port %d/udp",port);
+
+ hw.fd=sockfd;
+
+ return(1);
+}
+
+int udp_deinit(void)
+{
+ close(sockfd);
+ close(zerofd);
+ hw.fd=-1;
+ return(1);
+}
+
+char *udp_rec(struct ir_remote *remotes)
+{
+ if(!clear_rec_buffer()) return(NULL);
+ return(decode_all(remotes));
+}
+
+int udp_decode(struct ir_remote *remote,
+ ir_code *prep,ir_code *codep,ir_code *postp,
+ int *repeat_flagp,lirc_t *remaining_gapp)
+{
+ return(receive_decode(remote,prep,codep,postp,
+ repeat_flagp,remaining_gapp));
+}
+
+lirc_t udp_readdata(lirc_t timeout)
+{
+ static uint8_t buffer[8192];
+ static int buflen=0;
+ static int bufptr=0;
+ lirc_t data;
+ uint8_t packed[2];
+ uint32_t tmp;
+ fd_set rfd;
+ struct timeval tv;
+
+ /* Assume buffer is empty; LIRC should select on the socket */
+ hw.fd=sockfd;
+
+ /* If buffer is empty, get data into it */
+ if((bufptr+2)>buflen)
+ {
+ FD_ZERO(&rfd);
+ FD_SET(sockfd,&rfd);
+ tv.tv_sec=0;
+ tv.tv_usec=timeout;
+ if(select(sockfd+1,&rfd,NULL,NULL,&tv)!=1)
+ return 0;
+ if((buflen=recv(sockfd,&buffer,sizeof(buffer),0))<0)
+ {
+ logprintf(LOG_INFO,"Error reading from UDP socket");
+ return 0;
+ }
+ if(buflen&1)
+ buflen--;
+ if(buflen==0)
+ return 0;
+ bufptr=0;
+ }
+
+ /* Read as 2 bytes to avoid endian-ness issues */
+ packed[0]=buffer[bufptr++];
+ packed[1]=buffer[bufptr++];
+
+ /* TODO: This assumes the receiver is active low. Should
+ be specified by user, or autodetected. */
+ data = (packed[1] & 0x80) ? 0 : PULSE_BIT;
+
+ /* Convert 1/16384-seconds to microseconds */
+ tmp = (((uint32_t)packed[1])<<8) | packed[0];
+ tmp = ((tmp & 0x7FFF) * 1000000) / 16384;
+
+ data |= tmp & PULSE_MASK;
+
+ /* If our buffer still has data, give LIRC /dev/zero to select on */
+ if((bufptr+2)<=buflen)
+ hw.fd=zerofd;
+
+ return(data);
+}
+
+struct hardware hw_udp=
+{
+ "8765", /* "device" (port) */
+ -1, /* fd (socket) */
+ LIRC_CAN_REC_MODE2, /* features */
+ 0, /* send_mode */
+ LIRC_MODE_MODE2, /* rec_mode */
+ 0, /* code_length */
+ udp_init, /* init_func */
+ NULL, /* config_func */
+ udp_deinit, /* deinit_func */
+ NULL, /* send_func */
+ udp_rec, /* rec_func */
+ udp_decode, /* decode_func */
+ udp_readdata, /* readdata */
+ "udp"
+};
|