SageTV Community  

Go Back   SageTV Community > SageTV Products > SageTV Linux
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Linux Discussion related to the SageTV Media Center for Linux. Questions, issues, problems, suggestions, etc. relating to the SageTV Linux should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-08-2007, 09:09 PM
bcjenkins bcjenkins is offline
SageTVaholic
 
Join Date: Jan 2006
Posts: 3,764
How-to serial port tuning?

THIS PROBLEM SEEMS TO NOW BE RESOLVED

If you are using USB to serial in multiples (4 for me) and have issues with device mappings remaining consistent, see http://forums.sagetv.com/forums/show...9&postcount=16 for my udev rules and script.

B

PS - Leaving the error codes in post for searching.

Running Ubuntu 7.04 Server

Error:
Quote:
Wed 8/8 22:31:54.043 ERROR loading DirecTVSerialControl:java.lang.UnsatisfiedLinkError: no DirecTVSerialControl in java.library.path
I resolved that by linking to the file from /opt/sagetv/server.

Now when trying to tune; I see this in the log:
Quote:
Wed 8/8 23:05:34.216 DTVSerial opened handle on port COM1
Wed 8/8 23:05:34.216 DTVSerial testing to see if baud rate is 115200...
Wed 8/8 23:05:34.216 DTVSerial failed at 115200, reverting to 9600 baud.
Wed 8/8 23:05:34.216 DTVSerial failed writing, num=-1
Wed 8/8 23:05:34.216 DTVSerialX num=-1 cmd[0]=0xfa.
Wed 8/8 23:05:34.216 Incomplete COM Write on handle 49
Wed 8/8 23:05:34.216 DTVSerial opened handle on port COM1
Wed 8/8 23:05:34.216 DTVSerial testing to see if baud rate is 115200...
Wed 8/8 23:05:34.216 DTVSerial failed at 115200, reverting to 9600 baud.
Wed 8/8 23:05:34.216 DTVSerial failed writing, num=-1
Wed 8/8 23:05:34.216 DTVSerialX num=-1 cmd[0]=0xfa.
Wed 8/8 23:05:34.216 Incomplete COM Write on handle 49
My serial port is on /dev/ttyUSB0 and I deleted and recreated /dev/ttyS0 as a link to it. What does COM1 mean in linux?

TIA

B

Last edited by bcjenkins; 08-20-2007 at 03:58 AM. Reason: Problem resolved (Thanks _Demo_)
Reply With Quote
  #2  
Old 08-09-2007, 08:37 AM
_Demo_ _Demo_ is offline
Moderator
 
Join Date: Mar 2003
Posts: 863
Send a message via ICQ to _Demo_
COM1 is mapped to ttyS0 like you expected.

_Demo_
Reply With Quote
  #3  
Old 08-09-2007, 09:21 AM
bcjenkins bcjenkins is offline
SageTVaholic
 
Join Date: Jan 2006
Posts: 3,764
Is there a way to change the mapping, or can I symlink like I did? I just switched my main box from 2K3 to linux, and all this was working fine in windows.

Also, is there a way to make the default baud rate 9600?

TIA

B
Reply With Quote
  #4  
Old 08-09-2007, 12:33 PM
_Demo_ _Demo_ is offline
Moderator
 
Join Date: Mar 2003
Posts: 863
Send a message via ICQ to _Demo_
Creating a symlink should be fine. There is no way to specify a default rate of 9600 but it already falls back to 9600 when 115200 fails.

_Demo_
Reply With Quote
  #5  
Old 08-09-2007, 01:15 PM
bcjenkins bcjenkins is offline
SageTVaholic
 
Join Date: Jan 2006
Posts: 3,764
Upon reboot the /dev/ttyS0 symlink is destroyed and the node is put back. Is there a way to change the COM1 definition to be /dev/ttyUSB0?

TIA

B
Reply With Quote
  #6  
Old 08-09-2007, 03:42 PM
jpappas jpappas is offline
Sage User
 
Join Date: Feb 2007
Location: Texas USA
Posts: 47
UDev Rules...

Most current Linux distros use udev for device file management.

You can add a rule to one of the /etc/udev/rules.d files (probably 98-local.rules or similar)

Example rule:
KERNEL=="ttyUSB*", SYMLINK+="ttyS%n"

This will add a symlink for all numbered ttyUSB to ttyS. You could also create a link based on the serial number or product name or whatever. See tutorial below.

A good tutorial on udev rules:
http://www.reactivated.net/writing_udev_rules.html

HTH,
John
Reply With Quote
  #7  
Old 08-09-2007, 08:23 PM
bcjenkins bcjenkins is offline
SageTVaholic
 
Join Date: Jan 2006
Posts: 3,764
Thanks for that. According to /var/log/udev it set up a symlink on S0.
Quote:
UDEV [1186712657.836195] add /class/tty/ttyUSB0 (tty)
UDEV_LOG=3
ACTION=add
DEVPATH=/class/tty/ttyUSB0
SUBSYSTEM=tty
SEQNUM=2659
MAJOR=188
MINOR=0
UDEVD_EVENT=1
DEVNAME=/dev/ttyUSB0
DEVLINKS=/dev/ttyS0
We'll see if it tests out.

B

Still isn't tuning.

Quote:
Thu 8/9 22:29:36.721 Found next seq hdr code!
Thu 8/9 22:29:40.959 Loading 8x7 image from file /opt/sagetv/server/STVs/SageTV3/OSDStatusPlay.png
Thu 8/9 22:30:00.028 Incomplete COM Write on handle 71
Thu 8/9 22:30:00.028 DTVSerial opened handle on port COM1
Thu 8/9 22:30:00.028 DTVSerial testing to see if baud rate is 115200...
Thu 8/9 22:30:00.028 DTVSerial failed at 115200, reverting to 9600 baud.
Thu 8/9 22:30:00.028 DTVSerial failed writing, num=-1
Thu 8/9 22:30:00.028 DTVSerialX num=-1 cmd[0]=0xfa.
Thu 8/9 22:30:00.028 Incomplete COM Write on handle 71
Thu 8/9 22:30:00.035 switch encoding /var/media/tv/Roseanne-LikeaVirgin-72536-0.mpg
Thu 8/9 22:30:00.225 Found next seq hdr code!
Thu 8/9 22:30:09.954 Incomplete COM Write on handle 71
Thu 8/9 22:30:09.954 DTVSerial opened handle on port COM1
Thu 8/9 22:30:09.954 DTVSerial testing to see if baud rate is 115200...
Thu 8/9 22:30:09.954 DTVSerial failed at 115200, reverting to 9600 baud.
Thu 8/9 22:30:09.954 DTVSerial failed writing, num=-1
Thu 8/9 22:30:09.954 DTVSerialX num=-1 cmd[0]=0xfa.
Thu 8/9 22:30:09.954 Incomplete COM Write on handle 71
Thu 8/9 22:30:09.999 switch encoding /var/media/tv/TheAdventuresofJimmyNeutronBoyGenius-Stranded-388746-0.mpg
Thu 8/9 22:30:10.234 Found next seq hdr code!
Thu 8/9 22:30:49.625 Incomplete COM Write on handle 71
Thu 8/9 22:30:49.625 DTVSerial opened handle on port COM1
Thu 8/9 22:30:49.625 DTVSerial testing to see if baud rate is 115200...
Thu 8/9 22:30:49.625 DTVSerial failed at 115200, reverting to 9600 baud.
Thu 8/9 22:30:49.625 DTVSerial failed writing, num=-1
Thu 8/9 22:30:49.625 DTVSerialX num=-1 cmd[0]=0xfa.
Thu 8/9 22:30:49.625 Incomplete COM Write on handle 71
Thu 8/9 22:30:49.637 switch encoding /var/media/tv/Roseanne-LikeaVirgin-72536-1.mpg
Thu 8/9 22:30:49.770 Found next seq hdr code!

Last edited by bcjenkins; 08-09-2007 at 08:46 PM.
Reply With Quote
  #8  
Old 08-10-2007, 11:07 AM
bcjenkins bcjenkins is offline
SageTVaholic
 
Join Date: Jan 2006
Posts: 3,764
UDEV rule writing sucks!

So here's the deal..

I can't use just ttyS%n because it tries to link to an existing node. I tried using ttyS1% to register S10-S13 but is seems there is an artificial cap on how many ports the plugin will support. So the question is:

Can I write a udev rule like:

Code:
KERNEL=="ttyUSB*", SYMLINK+="ttyS{%n+4}"
and have it resolve to ttyS4-7 (4 usb adapters)

Failing this, I will add a ln -s /dev/ttyUSB0 /dev/ttyS4-7 to the startsage script. Although it seems silly to do so.

B
Reply With Quote
  #9  
Old 08-10-2007, 02:55 PM
bcjenkins bcjenkins is offline
SageTVaholic
 
Join Date: Jan 2006
Posts: 3,764
Well, if anyone knows a simpler way, I am all ears. I wrote the following rule:

Code:
KERNEL=="ttyUSB*", PROGRAM="/opt/sagetv/server/ttyUSB_converter %n", SYMLINK+="ttyS%c"
Which runs the little bit of code:
Code:
#!/bin/bash
echo $[4+$1]
Which produced:
Quote:
lrwxrwxrwx 1 root root 7 2007-08-10 16:51 /dev/ttyS4 -> ttyUSB0
What a pain!

Now on to tuning..

B

Which doesn't work!~ It hung at tuning and log indicated the tuning attempt stating it was stepping down the speed..

I let it sit for 5 mins, killed the PS window and the error log filled up with messages about the broken pipe. FYI - if I use the directv.pl from Myth, I can interact with the box all day long.

Last edited by bcjenkins; 08-10-2007 at 03:17 PM.
Reply With Quote
  #10  
Old 08-13-2007, 08:17 PM
jpappas jpappas is offline
Sage User
 
Join Date: Feb 2007
Location: Texas USA
Posts: 47
UDev Serial Numbers...

Since it seems that you have a large number of usb devices, I suggest that you use the serial number(s) of the devices to define a "static" device mapping via udev. For each device, use the device's serial number to define the device name.

ie: BUS=="usb", SYSFS{serial}=="L72010011070626380", SYMLINK+="epson_680"

Does that seem to be a workable solution?

John
Reply With Quote
  #11  
Old 08-14-2007, 03:04 AM
bcjenkins bcjenkins is offline
SageTVaholic
 
Join Date: Jan 2006
Posts: 3,764
Hi John,

Actually there isn't a serial number for each device. A coworker and I had this discussion last week. About the only thing unique is the following:

Quote:
looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb3/3-2/3-2:1.0'
KERNELS=="3-2:1.0"
Device list attached.

If I can key off the parent device, then I can tie the ttyUSB# to the physical port it is plugged in to. I was going to test a reboot this morning to see if the numbering remains the same. I assume udev is processing in a 1-n order by default.

B
Attached Files
File Type: txt ttyUSB.txt (11.7 KB, 270 views)
Reply With Quote
  #12  
Old 08-14-2007, 12:51 PM
bcjenkins bcjenkins is offline
SageTVaholic
 
Join Date: Jan 2006
Posts: 3,764
Almost there!

Now I know what my wife feels like after child birth!

Serial tuning is functioning, not sure how reliable yet because everytime I reboot the ttyUSB devices are moved around. Very annoying!

To resolve the serial tuning, I installed the kernel headers and downloaded a matching source from kernel.org. Side note, for some reason I could not easily find the right kernel source for Ubuntu.
  1. uname -r to determine kernel version
  2. download full source from kernel.org
  3. cp pl2303.h and pl2303.c to directory in ~/
  4. edit pl2303.c and look for: case B115200: baud = 115200; break;
  5. Change to case B115200: baud = 9600; break;
  6. Create custom Makefile
    Code:
    obj-m    := pl2303.o
    
    KDIR    := /lib/modules/$(shell uname -r)/build
    PWD    := $(shell pwd)
    
    default:
    	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
  7. make
  8. install the module
    Code:
    sudo install -m 644 pl2303.ko /lib/modules/2.6.20-15-server/kernel/drivers/usb/serial/pl2303.ko
  9. modprobe -r pl2303
  10. modprobe pl2303

This basically drops the baud rate down to 9600 for requests going in at 115200. I will go back to default drivers once SageTV figures out why it is hanging.

Since my USB devices seem to be non-unique, I think I can solve this by putting them all on one hub. Then I can make the nodes based on hub port number.
Reply With Quote
  #13  
Old 08-14-2007, 01:51 PM
_Demo_ _Demo_ is offline
Moderator
 
Join Date: Mar 2003
Posts: 863
Send a message via ICQ to _Demo_
Can you try the attached version without using your modified driver?

Thanks

_Demo_
Attached Files
File Type: zip libDirecTVSerialControlTest.zip (13.0 KB, 241 views)
Reply With Quote
  #14  
Old 08-14-2007, 06:32 PM
bcjenkins bcjenkins is offline
SageTVaholic
 
Join Date: Jan 2006
Posts: 3,764
No go with test lib

Quote:
Tue 8/14 20:01:49.076 DTVSerial opened handle on port COM5
Tue 8/14 20:01:49.076 DTVSerial testing to see if baud rate is 115200...
Tue 8/14 20:01:49.578 DTVSerial response num=0 cmd[0]=0xfa cmd[1]=0x84 cmd[2]=0xc5 cmd[3]=0xb3 cmd[4]=0x44 cmd[5]=0x2b
Tue 8/14 20:01:49.578 DTVSerial failed at 115200, reverting to 9600 baud.
Code:
/opt/sagetv/server/irtunerplugins/libDirecTVSerialControl.so:
        linux-gate.so.1 =>  (0xffffe000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7ec8000)
        libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7ea1000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7e94000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7d53000)
        /lib/ld-linux.so.2 (0x80000000)
Are there any other debugs I can turn on for info?

B
Reply With Quote
  #15  
Old 08-17-2007, 08:24 AM
_Demo_ _Demo_ is offline
Moderator
 
Join Date: Mar 2003
Posts: 863
Send a message via ICQ to _Demo_
Could you try the latest beta version and tell me the results. It has updated file.

Thanks

_Demo_
Reply With Quote
  #16  
Old 08-19-2007, 12:44 PM
bcjenkins bcjenkins is offline
SageTVaholic
 
Join Date: Jan 2006
Posts: 3,764
Took a few days..

Quote:
Sun 8/19 11:18:34.936 DTVSerial opened handle on port COM6
Sun 8/19 11:18:34.936 DTVSerial testing to see if baud rate is 115200...
Sun 8/19 11:18:35.435 DTVSerial response num=0 cmd[0]=0xfa cmd[1]=0x84 cmd[2]=0xca cmd[3]=0xb3 cmd[4]=0x44 cmd[5]=0x8b
Sun 8/19 11:18:35.435 DTVSerial failed at 115200, reverting to 9600 baud.
Sun 8/19 11:18:35.455 DTVSerialX num=1 cmd[0]=0x0.
Sun 8/19 11:18:35.455 DTVSerial Unknown Command Response on handle 82 of 0x4
Sun 8/19 11:18:35.739 DTVSerial opened handle on port COM6
Sun 8/19 11:18:35.739 DTVSerial testing to see if baud rate is 115200...
Sun 8/19 11:18:36.239 DTVSerial response num=0 cmd[0]=0xfa cmd[1]=0x84 cmd[2]=0xca cmd[3]=0xb3 cmd[4]=0x24 cmd[5]=0x8d
Sun 8/19 11:18:36.239 DTVSerial failed at 115200, reverting to 9600 baud.
Sun 8/19 11:18:36.260 DTVSerialX num=1 cmd[0]=0xf2.
Sun 8/19 11:18:36.260 DTVSerial got a command error, switching to other base for handle
Sun 8/19 11:18:36.270 DTVSerial Valid Command Recognized for handle 82
Sun 8/19 11:18:36.290 DTVSerial Set Top is Processing Request for handle 82
Sun 8/19 11:18:36.290 DTVSerial Unknown Command Response on handle 82 of 0xf5
Channel changing seems to be functioning (THANKS! ), I will have to perform a more careful analysis. The boxes I have are D11-100s is there something to be done about the last log entry?

However, my USB to serial adapter scripts needed some further work.. Previously, I tried plugging all 4 devices into a cheap USB 2.0 hub I had. I think it was too much so I had to put 2 of them back on to the standard ports. At least now though I have a unique way to identify each pair of devices. Also each pair loads in the same order every time. Without further ado:

bash script called by udev rules:
Code:
#!/bin/bash

if echo $2 | grep -q no; then
  if [ $[6+$1] -gt 7 ]; then
    echo $[4+$1]
  else
    echo $[6+$1]
  fi
elif [ $[6+$1] -gt 7 ]; then
  echo $[2+$1]
else
  echo $[4+$1]
fi
udev rules:

Code:
SUBSYSTEMS=="usb" , KERNELS=="?-?.?:?.0" , DRIVERS=="pl2303" , PROGRAM="/opt/sagetv/server/ttyUSB_converter %n hub", SYMLINK+="ttyS%c"
SUBSYSTEMS=="usb" , KERNELS=="?-?:?.0" , DRIVERS=="pl2303" , PROGRAM="/opt/sagetv/server/ttyUSB_converter %n nohub", SYMLINK+="ttyS%c"
Because the load order differs between the chipsets on reboots I had to make the above changes. I also wanted to keep it in 1 script.

B

Last edited by bcjenkins; 09-06-2007 at 03:38 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial port on Motorola Cable (Comcast) box? Fountainhead Hardware Support 2 07-16-2007 02:58 PM
Channel Changing Issues and Serial Com Port mike1961 SageTV Beta Test Software 7 02-21-2007 02:04 PM
D11 linkup hardware and cabling options - calling all D11 owners IncredibleHat Hardware Support 7 01-14-2007 02:45 AM
serial port channel change Ryel Hardware Support 1 11-21-2006 02:44 PM
What's the trick to get SageTV to accept COM port 5 for serial DirecTV tuning? mkanet Hardware Support 6 08-21-2006 08:38 PM


All times are GMT -6. The time now is 10:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.