|
From: Jelle F. <je...@fo...> - 2007-04-18 05:25:01
|
--- lirc-0.8.2pre1/configure.in 2007-03-17 08:45:02.000000000 -0400
+++ lirc-0.8.2pre1-jelle/configure.in 2007-04-09 02:04:52.000000000 -0400
@@ -163,6 +163,7 @@
(tira) \
(uirt2) \
(uirt2_raw) \
+ (usbx) \
(usb_uirt_raw) \
(udp)"
@@ -278,7 +279,7 @@
irman, irreal, it87, knc_one, kworld,
leadtek_0007, leadtek_0010, leadtek_pvr2000,
livedrive_midi, livedrive_seq, logitech,
- lptX, mceusb, mceusb2, mediafocusI,
+ lptX, mceusb, mceusb2, usbx, mediafocusI,
mouseremote, mouseremote_ps2, mp3anywhere,
nslu2,packard_bell, parallel, pcmak,
pcmak_usb, pctv, pixelview_bt878,
@@ -472,6 +473,9 @@
uirt2_raw|usb_uirt_raw)
hw_module="${hw_module} hw_uirt2_raw.o hw_uirt2_common.o serial.o receive.o transmit.o"
;;
+ usbx)
+ hw_module="${hw_module} hw_usbx.o serial.o"
+ ;;
esac
done
#remove duplicates
@@ -1085,6 +1089,11 @@
hw_module="hw_uirt2_raw.o hw_uirt2_common.o serial.o receive.o transmit.o"
HW_DEFAULT="hw_usb_uirt_raw"
fi
+if test "$driver" = "usbx"; then
+ lirc_driver="none"
+ hw_module="hw_usbx.o serial.o"
+ HW_DEFAULT="hw_usbx"
+fi
#END HARDWARE HEURISTIC
--- lirc-0.8.2pre1/daemons/hw-types.c 2007-02-28 15:44:52.000000000 -0500
+++ lirc-0.8.2pre1-jelle/daemons/hw-types.c 2007-04-09 02:04:52.000000000 -0400
@@ -39,6 +39,7 @@
extern struct hardware hw_uirt2;
extern struct hardware hw_uirt2_raw;
extern struct hardware hw_usb_uirt_raw;
+extern struct hardware hw_usbx;
#ifndef HW_DEFAULT
@@ -120,6 +121,7 @@
&hw_uirt2,
&hw_uirt2_raw,
&hw_usb_uirt_raw,
+ &hw_usbx,
#else
&HW_DEFAULT,
#endif
--- lirc-0.8.2pre1/daemons/serial.c 2006-11-22 16:28:39.000000000 -0500
+++ lirc-0.8.2pre1-jelle/daemons/serial.c 2007-04-17 21:43:08.000000000 -0400
@@ -26,7 +26,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
-
+#include <linux/serial.h> /* for 'struct serial_struct' to set custom baudrates */
#include "lircd.h"
int tty_reset(int fd)
@@ -116,6 +116,8 @@
{
struct termios options;
int speed;
+ int use_custom_divisor = 0;
+ struct serial_struct serinfo;
switch(baud)
{
@@ -146,10 +148,76 @@
case 115200:
speed=B115200;
break;
+#ifdef B230400
+ case 230400:
+ speed=B230400;
+ break;
+#endif
+#ifdef B460800
+ case 460800:
+ speed=B460800;
+ break;
+#endif
+#ifdef B500000
+ case 500000:
+ speed=B500000;
+ break;
+#endif
+#ifdef B576000
+ case 576000:
+ speed=B576000;
+ break;
+#endif
+#ifdef B921600
+ case 921600:
+ speed=B921600;
+ break;
+#endif
+#ifdef B1000000
+ case 1000000:
+ speed=B1000000;
+ break;
+#endif
+#ifdef B1152000
+ case 1152000:
+ speed=B1152000;
+ break;
+#endif
+#ifdef B1500000
+ case 1500000:
+ speed=B1500000;
+ break;
+#endif
+#ifdef B2000000
+ case 2000000:
+ speed=B2000000;
+ break;
+#endif
+#ifdef B2500000
+ case 2500000:
+ speed=B2500000;
+ break;
+#endif
+#ifdef B3000000
+ case 3000000:
+ speed=B3000000;
+ break;
+#endif
+#ifdef B3500000
+ case 3500000:
+ speed=B3500000;
+ break;
+#endif
+#ifdef B4000000
+ case 4000000:
+ speed=B4000000;
+ break;
+#endif
default:
- LOGPRINTF(1,"tty_setbaud(): bad baud rate %d",baud);
- return(0);
- }
+ speed=B38400;
+ use_custom_divisor=1;
+ break;
+ }
if(tcgetattr(fd, &options)==-1)
{
LOGPRINTF(1,"tty_setbaud(): tcgetattr() failed");
@@ -164,6 +232,24 @@
LOGPERROR(1,"tty_setbaud()");
return(0);
}
+ if (use_custom_divisor)
+ {
+ if(ioctl(fd, TIOCGSERIAL, &serinfo) < 0)
+ {
+ LOGPRINTF(1,"tty_setbaud(): TIOCGSERIAL failed");
+ LOGPERROR(1,"tty_setbaud()");
+ return(0);
+ }
+ serinfo.flags &= ~ASYNC_SPD_MASK;
+ serinfo.flags |= ASYNC_SPD_CUST;
+ serinfo.custom_divisor = serinfo.baud_base / baud;
+ if(ioctl(fd, TIOCSSERIAL, &serinfo) < 0)
+ {
+ LOGPRINTF(1,"tty_setbaud(): TIOCSSERIAL failed");
+ LOGPERROR(1,"tty_setbaud()");
+ return(0);
+ }
+ }
return(1);
}
--- lirc-0.8.2pre1/setup.data 2007-02-28 15:44:52.000000000 -0500
+++ lirc-0.8.2pre1-jelle/setup.data 2007-04-09 02:04:52.000000000 -0400
@@ -132,6 +132,7 @@
usb_uirt_raw: "USB-UIRT"
mceusb: "Windows Media Center Remotes (old version, MicroSoft USB ID)"
mceusb2: "Windows Media Center Remotes (new version, Philips et al.)"
+ usbx: "ADSTech USBX-707 USB IR Blaster"
param_type: \
act200l \
@@ -170,8 +171,9 @@
param_type: \
pcmak_usb \
tira \
- usb_uirt_raw
- ttyUSB:
+ usb_uirt_raw \
+ usbx
+ ttyUSB:
param_type: \
adaptec \
@@ -346,5 +348,6 @@
default_param: \
pcmak_usb \
tira \
- usb_uirt_raw
+ usb_uirt_raw \
+ usbx
ttyUSB1:
--- lirc-0.8.2pre1/setup-driver.sh 2007-03-17 08:46:25.000000000 -0400
+++ lirc-0.8.2pre1-jelle/setup-driver.sh 2007-04-09 02:04:52.000000000 -0400
@@ -273,7 +273,8 @@
j "Streamzap PC Remote" \
k "USB-UIRT" \
l "Windows Media Center Remotes (old version, MicroSoft USB ID)" \
- m "Windows Media Center Remotes (new version, Philips et al.)" 2> $TEMP
+ m "Windows Media Center Remotes (new version, Philips et al.)" \
+ n "ADSTech USBX-707 USB IR Blaster" 2> $TEMP
if test "$?" = "0"; then
{
set `cat $TEMP`
@@ -301,6 +302,7 @@
elif test "$1" = "k"; then LIRC_DRIVER=usb_uirt_raw; DRIVER_PARAMETER=ttyUSB1; DRIVER_PARAM_TYPE=ttyUSB;
elif test "$1" = "l"; then LIRC_DRIVER=mceusb; DRIVER_PARAMETER=none; DRIVER_PARAM_TYPE=none;
elif test "$1" = "m"; then LIRC_DRIVER=mceusb2; DRIVER_PARAMETER=none; DRIVER_PARAM_TYPE=none;
+ elif test "$1" = "n"; then LIRC_DRIVER=usbx; DRIVER_PARAMETER=ttyUSB1; DRIVER_PARAM_TYPE=ttyUSB;
fi
}
else
--- lirc-0.8.2pre1/daemons/hw_usbx.c 2007-04-17 23:34:14.000000000 -0400
+++ lirc-0.8.2pre1-jelle/daemons/hw_usbx.c 2007-04-17 23:29:12.000000000 -0400
@@ -0,0 +1,166 @@
+/*****************************************************************************
+ ** hw_usbx.c ****************************************************************
+ *****************************************************************************
+ * Routines for the ADSTech USBX-707 USB IR Blaster
+ *
+ * Only receiving is implemented
+ *
+ * Information on how to send with this device is greatly appreciated...
+ *
+ * Copyright (C) 2007 Jelle Foks <je...@fo...>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+#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 <errno.h>
+#include <termios.h>
+
+#include "hardware.h"
+#include "receive.h"
+#include "serial.h"
+#include "ir_remote.h"
+#include "lircd.h"
+#include "hw_usbx.h"
+
+extern int errno;
+unsigned char b[6];
+lirc_t gap;
+ir_code code;
+
+#define CODE_LENGTH 64
+struct hardware hw_usbx = {
+ "/dev/ttyUSB0", /* Default device */
+ -1, /* fd */
+ LIRC_CAN_REC_LIRCCODE, /* Features */
+ 0, /* send_mode */
+ LIRC_MODE_LIRCCODE, /* rec_mode */
+ CODE_LENGTH, /* code_length */
+ usbx_init, /* init_func */
+ NULL, /* config_func */
+ usbx_deinit, /* deinit_func */
+ NULL, /* send_func */
+ usbx_rec, /* rec_func */
+ usbx_decode, /* decode_func */
+ NULL, /* ioctl_func */
+ NULL, /* readdata */
+ "usbx"
+};
+
+int usbx_decode (struct ir_remote *remote, ir_code *prep, ir_code *codep,
+ ir_code *postp, int *repeat_flagp, lirc_t *remaining_gapp)
+{
+ if( remote->flags&CONST_LENGTH ||
+ !map_code(remote, prep, codep, postp,
+ 0, 0, CODE_LENGTH, code, 0, 0))
+ {
+ return 0;
+ }
+ *repeat_flagp = (unsigned long long) *codep & 1; /* the lsb in the code is the repeat flag */
+ remote->toggle_bit_mask_state = *repeat_flagp; /* without this. a repeat sequence from lircd erroneously starts with two non-repeat presses */
+ *remaining_gapp=remote->gap;
+
+ LOGPRINTF(1,"pre: %llx",(unsigned long long) *prep);
+ LOGPRINTF(1,"code: %llx",(unsigned long long) *codep);
+ LOGPRINTF(1,"post: %llx",(unsigned long long) *postp);
+ LOGPRINTF(1,"repeat_flag: %d",*repeat_flagp);
+ LOGPRINTF(1,"gap: %lu",(unsigned long) gap);
+ LOGPRINTF(1,"rem: %lu",(unsigned long) remote->remaining_gap);
+ return 1;
+}
+
+int usbx_init(void)
+{
+ if(!tty_create_lock(hw.device))
+ {
+ logprintf(LOG_ERR,"could not create lock files");
+ return 0;
+ }
+ if ( (hw.fd = open (hw.device, O_RDWR | O_NONBLOCK | O_NOCTTY)) < 0)
+ {
+ tty_delete_lock ();
+ logprintf (LOG_ERR, "Could not open the '%s' device",
+ hw.device);
+ return 0;
+ }
+ LOGPRINTF(1, "device '%s' opened", hw.device);
+
+ if(!tty_reset(hw.fd) ||
+ !tty_setbaud(hw.fd, 300000) ||
+ !tty_setrtscts(hw.fd, 1))
+ {
+ usbx_deinit();
+ return 0;
+ }
+
+ return 1;
+}
+
+int usbx_deinit (void)
+{
+ close(hw.fd);
+ sleep(1);
+ tty_delete_lock();
+ return 1;
+}
+
+char *usbx_rec (struct ir_remote *remotes)
+{
+ char *m;
+ int i, x;
+
+ x = 0;
+ for (i = 0 ; i < 6; i++)
+ {
+ if (i > 0)
+ {
+ if (!waitfordata(20000))
+ {
+ LOGPRINTF(LOG_ERR,"timeout reading byte %d",i);
+ break;
+ }
+ }
+ if (read(hw.fd, &b[i], 1) != 1)
+ {
+ LOGPRINTF(LOG_ERR, "reading of byte %d failed.", i);
+ break;
+ }
+ LOGPRINTF(1, "byte %d: %02x", i, b[i]);
+ x++;
+ }
+ code = 0;
+ for ( i = 0 ; i < x ; i++ )
+ {
+ code = code << 8;
+ code |= ((ir_code) b[i]);
+ }
+
+ LOGPRINTF(1," -> %0llx",(unsigned long long) code);
+
+ m = decode_all(remotes);
+ return m;
+}
--- lirc-0.8.2pre1/daemons/hw_usbx.h 2007-04-17 23:34:15.000000000 -0400
+++ lirc-0.8.2pre1-jelle/daemons/hw_usbx.h 2007-04-09 02:04:52.000000000 -0400
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ ** hw_usbx.h ****************************************************************
+ *****************************************************************************
+ *
+ * Copyright (C) 2007 Jelle Foks <je...@fo...>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef HW_USBX_H
+#define HW_USBX_H
+
+#include "drivers/lirc.h"
+
+int usbx_decode (struct ir_remote *remote,
+ ir_code *prep,
+ ir_code *codep,
+ ir_code *postp,
+ int *repeat_flagp,
+ lirc_t *remaining_gapp);
+int usbx_init (void);
+int usbx_deinit (void);
+char *usbx_rec (struct ir_remote *remotes);
+
+#endif
+
+
|