[mythtv-users] Lirc and jvc_send?

jasonmiller jasonmiller at micron.com
Mon May 12 15:19:14 EDT 2003


I posted this a while back but I'm not sure it made it through the size filter...

Karl Bongers (the author of jvc_send) was kind enough to supply me with a small little C program that creates a raw format lircd.conf entry for the jvc/dishnetwork boxes.  The resultant lirc.conf works fine with lircd so you can send and receive reliably without using any hacks like jvc_send.  Depending on the particulars of your setup, you may need to tweak with the four timing parameters a little bit to get optimal perormance.  I just started with the defaults below, installed the lirc.conf, then ran irsend 12345678901234567890 while watching the guide window.  If all 20 numbers went by without missing any it was good enough for me.  Only had to make two passes at it.  Here's the code...


/*--------------------------------------------------
 jvc_raw.c - Make special raw lircd.conf definitions.
 ---------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>

#include <linux/ioctl.h>
#include <asm/types.h>
#define LIRC_SET_SEND_CARRIER          _IOW('i', 0x00000013, __u32)
#define LIRC_SET_SEND_DUTY_CYCLE       _IOW('i', 0x00000015, __u32)

#define MODULATION_FREQ 57600
//#define MODULATION_FREQ 38000

/* 0 to 100, where 100=strongest? */
#define DUTY_CYCLE 50

/* 1 block takes up 16bits*2+2, or 34 samples.  lirc_serial
   has a 256 sample buffer, so we can send max 7 back to back
   signals. */
#define NUM_BACK_TO_BACK 6

#define POWER_BITS 0xf7ff; /* power button bits */
//#define PULSE_LEN 350
//#define HEADER_SPACE 6000
//#define ONE_LEN 2700
//#define ZERO_LEN 1700
#define PULSE_LEN 350
#define HEADER_SPACE 6050
#define ONE_LEN 2600
#define ZERO_LEN 1600

static unsigned int data[1024];
int fd;
int duty_cycle, freq;
int num_times_to_send = 1;

typedef struct {
  char str[40];
  unsigned int code;
} Lookup;

Lookup lookup[] = {
  {"tv/video",      0x000000000000A3FF},
  {"power",         0x000000000000F7FF},
  {"menu",          0x000000000000D3FF},
  {"page_up",       0x000000000000C3EF},
  {"page_down",     0x000000000000E3EF},
  {"guide",         0x000000000000AFFF},
  {"pointer_up",    0x00000000000097FF},
  {"pointer_left",  0x0000000000008FFF},
  {"pointer_right", 0x0000000000009FFF},
  {"pointer_down",  0x00000000000087FF},
  {"select",        0x000000000000BFFF},
  {"recall",        0x00000000000093FF},
  {"info",          0x000000000000FFFF},
  {"view",          0x000000000000A7FF},
  {"cancel",        0x000000000000B7FF},
  {"sys_info",      0x0000000000006FFF},
  {"record",        0x00000000000083FF},
  {"1",             0x000000000000EFFF},
  {"2",             0x000000000000EBFF},
  {"3",             0x000000000000E7FF},
  {"4",             0x000000000000DFFF},
  {"5",             0x000000000000DBFF},
  {"6",             0x000000000000D7FF},
  {"7",             0x000000000000CFFF},
  {"8",             0x000000000000CBFF},
  {"9",             0x000000000000C7FF},
  {"0",             0x000000000000BBFF},
  {"*",             0x0000000000006BFF},
  {"#",             0x00000000000067FF},
  {"", 0} };
 
int main(int argn, char *argv[])
{
  int i,j,k,li;
  unsigned int v;

printf("begin remote\n \
\n \
  name   JVC_RAW\n \
  flags CONST_LENGTH|RAW_CODES\n \
  eps            30\n \
  aeps          100\n \
\n \
  ptrail          0\n \
  repeat     0     0\n \
  gap    100000\n \
\n \
      begin raw_codes\n");



  li = 0;
  while (lookup[li].str[0] != 0) {
    /* fill up our buffer with signal data to send driver */
    j = 0;
    for (k=0; k<NUM_BACK_TO_BACK; k++)
    {
      data[j++] = PULSE_LEN;
      data[j++] = HEADER_SPACE;
  
      v = lookup[li].code;
  
      for (i=0; i<16; i++) {
        data[j++] = PULSE_LEN;
        if (v & 0x8000)
             data[j++] = ONE_LEN;
        else data[j++] = ZERO_LEN;
        v <<= 1;
      }
    }
    --j;

    printf("\n  name    %s", lookup[li].str);
    for (k=0; k<j; k++)
    {
      if ((k % 6) == 0) printf("\n     ");
      printf("%5d  ", data[k]);
    }

    ++li;
  }
  printf("\n \
      end raw_codes\n \
\n \
end remote\n");

  return(EXIT_SUCCESS);
}


-----Original Message-----
From: Michael Hill [mailto:mikehillny at yahoo.com]
Sent: Monday, May 12, 2003 1:12 PM
To: Discussion about mythtv
Subject: Re: [mythtv-users] Lirc and jvc_send?


Are you using two seperate lirc modules as well ?  Can you give more detail on
how to get this to work ?

Thanks, Mike
--- Owen Williams <ywwg at usa.net> wrote:
> On Mon, 2003-04-14 at 12:01, mythtv-users-request at snowman.net wrote:
> >    8. Lirc and jvc_send? (jasonmiller)
> > Date: Mon, 14 Apr 2003 08:17:53 -0600
> > From: jasonmiller <jasonmiller at micron.com>
> > To: "'mythtv-users at snowman.net'" <mythtv-users at snowman.net>
> > Subject: [mythtv-users] Lirc and jvc_send?
> > Message-ID:
> <3607D767B8E1D311A24F0008C7590A961218BC09 at ntexchange07.micron.com>
> > Content-Type: text/plain;
> > 	charset="iso-8859-1"
> > MIME-Version: 1.0
> > Precedence: list
> > Reply-To: Discussion about mythtv <mythtv-users at snowman.net>
> > Message: 8
> > 
> > Is anyone succesfully using lirc with a receiver/transmitter combo to both
> control mythtv with a remote and control a jvc/dishnetwork box with jvc_send?
>  My receiver works great but when irxevent is running, the jvc_send fails
> because it can't open the lirc device.  If irxevent isn't running it works
> just fine.  I'm assuming irxevent is polling /dev/lirc thus locking it up but
> I would think that would be a problem for any transmitter.  
> 
> 
> I am currently using an irman to receive remote signals and an ir
> blaster to send to my cable box.  It's actually quite easy to get two
> lircd drivers running simultaneously.  Install the first one as normal,
> and save all of the utilities it builds (the driver, irexec, etc).  Then
> edit the config.h.in file, changing the following:
> 
> change all the devices to lirc2 and whatnot
> increment the default port number
> 
> then reconfigure and recompile, but don't install.  Make sure the new
> devices are properly created.
> 
> Now, you have two copies of lircd, irexec, and all those.  I renamed my
> daemons lircd-irman and lircd-blaster.  Then I copied the rc
> corresponding to the irblaster build to /usr/local/bin, and also copied
> the irexec and irxevent corresponding to the irman build.
> 
> So now, when it wants to change the channel, the rc program is built
> against one set of devices, and the ir* programs are built against the
> other device.  It works perfectly.
> 
> owen williams
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at snowman.net
> http://lists.snowman.net/cgi-bin/mailman/listinfo/mythtv-users


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
_______________________________________________
mythtv-users mailing list
mythtv-users at snowman.net
http://lists.snowman.net/cgi-bin/mailman/listinfo/mythtv-users


More information about the mythtv-users mailing list