[mythtv-users] "Watch TV" not working

Larry Sanderson larry.sanderson at gmail.com
Wed Dec 12 20:22:38 UTC 2007


Ok, can you tell me how they've defined WORD and DWORD?  I would guess 
that WORD is a 2-byte unsigned int, and DWORD is a 4-byte unsigned int.  
Either that or a 4-byte and 8-byte value respectively.

You have a few problems in your code:

1) You are writing out an int (writeInt) for both DWORD and WORD 
values... you need to use the right sized integer values to sync up.
2) You are writing out much shorter strings than expected.  The 
structure has defined each string's length, and you need to match that.
3) You have pre-calculated the size of these structures, and incorrectly 
at that.  I show below how the size can be calculated at runtime.

Let's assume a 2-byte and 4-byte integer for WORD and DWORD (this will 
correspond to a short and int in Java.  The 4/8 variety would 
correspond to int/long)

Here's a brief example of a reasonable implementation of this (note: I 
did not try to compile it, so there's probably a few bugs/typos):

FEDTTransferrable.java:

import java.io.*;

// a common interface for all FEDT structures
public interface FEDTTransferrable {
    public int getSize();
    public void write(DataOutputStream out) throws IOException;
}


FEDTIPHeader.java:

import java.io.*;

public class FEDTIPHeader implements FEDTTransferrable {
    private static final byte[] SIG = "FEDTINT".getBytes("US-ASCII");
    private short messId;
    private FEDTTransferrable body;

    public FEDTIPHeader(short messId, FEDTTransferrable body) {
        this.messId = messId;
        this.pcData = body;
    }
    
    public int getSize() {
        // 7-bytes for pcSig, 2-bytes for messId, 4-bytes for size
        // and the contents of body
        return 13 + pcData.getSize();
    }

    public void write(DataOutputStream out) throws IOException {
        out.write(SIG);
        out.writeShort(messId);
        out.writeInt(body.getSize());
        pcData.write(out);
    }
}

FEDTIntroduction.java:

import java.io.*;

public class FEDTIntroduction implements FEDTTransferrable {
    private byte[] name = new byte[31];
    private byte[] companyName = new byte[31];
    private byte[] supportPhone = new byte[11];
    private boolean supportI;
    private boolean supportII;
    private boolean supportIII;


    public FEDTIntroduction(String name, String companyName,
        String supportPhone, boolean supportI, boolean supportII, 
        boolean supportIII)
    {
        byte[] temp = name.getBytes("US-ASCII");
        System.arraycopy(temp, 0, this.name, 0,
            Math.min(temp.length, this.name.length);
        temp = companyName.getBytes("US-ASCII");
        System.arraycopy(temp, 0, this.companyName, 0,
            Math.min(temp.length, this.companyName.length);
        temp = supportPhone.getBytes("US-ASCII");
        System.arraycopy(temp, 0, this.supportPhone, 0,
            Math.min(temp.length, this.supportPhone.length);
        
        this.supportI = supportI;
        this.supportII = supportII;
        this.supportIII = supportIII;
    }
    
    public int getSize() {
        // 31-bytes for name, 31-bytes for companyName, 
        // 11-bytes for supportPhone, and 1 byte each for
        // support-I,II,and III
        return 76;
    }

    public void write(DataOutputStream out) throws IOException {
        out.writeInt(getSize());
        out.write(name);
        out.write(companyName);
        out.write(supportPhone);
        out.writeBoolean(supportI);
        out.writeBoolean(supportII);
        out.writeBoolean(supportIII);
    }
}


Test.java:

import java.io.*;
import java.net.*;

public class Test {
    public static void main(String[] args) throws Exception {
        FEDTIntroduction intro = new FEDTIntroduction(
            "ESM", "Metron Aviation", "7039756282",
            false, false, false);
        FEDTIPHeader header = new FEDTIPHeader(2003, intro);
        
        Socket s = new Socket("host", port);
        OutputStream out = s.getOutputStream();
        DataOutputStream dout = new DataOutputStream(out);
        
        header.write(dout);
        dout.flush();

        InputStream in = s.getInputStream();
        int b;
        while ((b = in.read()) != -1) {
            System.out.write(b);
        }
        
        s.close();
    }
}


On Wednesday 12 December 2007 02:33:02 pm Jason Garrett wrote:
> No, I cannot record shows. I will check the logs when I get home.
>
> On Dec 12, 2007 1:08 PM, Bill Omer <bill.omer at gmail.com> wrote:
> > On Dec 12, 2007 1:48 PM, Asher <freedenizen at gmail.com> wrote:
> > > On Dec 11, 2007 8:50 PM, Jason Garrett <garrett.jason at gmail.com> 
wrote:
> > > > I just finished installing the latest version of KnoppMyth.  It
> > > > appeared to recognize my Tuner Card, however, when i click
> > > > "Watch TV", the screen goes black for about 15-20 seconds and
> > > > then goes back to the main Myth TV screen.  I have a PVR-150
> > > > tuner card.  I'm currently hooked up to my monitor, not a TV. 
> > > > I have tested the cable going into the Tuner Card by hooking it
> > > > up to a tv, and I do have a good cable.
> > >
> > > Can you record shows?  Any information from the frontend or
> > > backend logs?
> >
> > You could start myth like so to get more info:
> >
> > mythfrontend -l mythfrontend.log
> >
> > Try to watch tv, let it fail, then look at the log file which was
> > created in the directory you started the frontend from.  It should
> > help pinpoint whats going on.   If it doesn't contain anything
> > helpful, add "-v all" to the mythfrontend command.
> >
> > _______________________________________________
> > mythtv-users mailing list
> > mythtv-users at mythtv.org
> > http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users



More information about the mythtv-users mailing list