PDA

View Full Version : Generic Serial Support for RCA DSS Receiver



JimHugh
January 23rd, 2003, 07:52 PM
I am able to send commands to my RCA DirectTV DSS Reciever serial port using Mark Feichtner's Generic Serial Support Plugin 3.0.9 to change channels and navigate the guide etc... (Thanks Mark! And Ron of course!)

Sending the commands and not checking the return codes is working fine for my purposes, BUT, there are three commands that allow you to query the receiver for the Date, Current Channel and Signal Strength.

I don't know LUA (yet), but I did look at and understand the Replay Plus samples (for the most part)...

The one area that I don't know how to work around is how to accept a variable length of recieved data that does not have a termination character.

i.e. the GetChannel returns four bytes, The Signal Strength returns three and the GetDate returns nine bytes. None of them with a terminator!

I wrote a program in Visual Basic 6 that allows me to send the commands. Here is the GetDate function and how I parse the return string to determine the date.

How can I handle this with Girder, LUA and the Generic Serial plugin?

Once I get it working 100%, I'll upload the DirectTV Serial DSS Group Export that I've created.

Private Function GetDate(ByRef comm As MSComm) As Date
' Hex
'09 08 07 12 1c 03 03
' mm dd hh nn ss dw
' Dec
' 08 07 18 28 03 03
' 8/7/ 18:28:03 Tuesday
'Sample LastResponse = F00A0117132D3404F4
' Translated is 1/23/2003 7:45:52 PM
Dim dt As Date
Dim s As String

If DSS_Command("11", comm) Then
s = CLng("&H" & Mid(LastResponse, 5, 2)) & "/" & _
CLng("&H" & Mid(LastResponse, 7, 2)) & "/" & _
Year(Now) & " " & _
CLng("&H" & Mid(LastResponse, 9, 2)) & ":" & _
CLng("&H" & Mid(LastResponse, 11, 2)) & ":" & _
CLng("&H" & Mid(LastResponse, 13, 2))
GetDate = CDate(s)
End If
End Function

Mark F
January 24th, 2003, 02:01 AM
Not having a terminator is OK. You can either set the fixed receive data length to 1 (and build your own strings until you have the right amount) or set the plugin up for variable length strings (with a receive timeout) and deal with that. To know which would be more appropriate, I need to understand the received data protocol a bit more.

Does the received data protocol have any type of indicator in the stream for the type of data being received? Do the different returned packets START with different values? Your example shows F00A as the starting bytes of the data coming back in a DATE packet. Is it always that value and do the other two packets start with something different but consistent? If so, the LUA script could key off the starting characters and decide the correct length.

If you could attach a URL to a document with the protocol, I could help you figure out the LUA parsing code a bit easier. :)

JimHugh
January 24th, 2003, 07:42 AM
http://www.pcmx.net/dtvcon/ has the basic protocol defined.

I had to figure out how to parse the date string, but the channel and signal is just a hex to decimal conversion.

I have attached a PortMon log with each of the three conversations.

Based on your reply, it appears that I will have to save the request type in a variable, then build the string a byte at a time. Each request has a fixed length return string, but three different lengths.

F0 should start each return string. But F0 can also be valid data. i.e. channel 240.

Based on watching the DSS with PortMon, it does not randomly send strings, only in response to commands issued to it. So a combo of a timer, a string builder and remembering which command was most recently sent should do it.

mihooper
January 24th, 2003, 07:55 AM
Jim,

My suggestion is......take the time to learn LUA...it's worth it. Especially when you need accurate timing on serial comms.

For what it's worth, I use NetRemote to send a channel-formatted string to a LUA script in Girder. Here's the script to parse the channel number:

--format of pld2 = "123..,ABC.."
CommandString = (pld2)
--find length of Command String
CommandStrLen = strlen(CommandString)
--find length of Channel number
ChannelLen = (strfind(CommandString,",")-1)
--extract channel number
ChannelNumber = strsub(CommandString,1,ChannelLen)
--extract channel name
ChannelName = strsub(CommandString,ChannelLen+2,CommandStrLen)
--set receiver code for Echostar receiver
DeviceCode = '05013307'
--send each digit of channel number
for i = 1,ChannelLen do
ButtonNumber = format ("%1$02x", strsub (ChannelNumber,i,i))
if ButtonNumber=="00" then ButtonNumber="0A" end
Button(ButtonNumber)
end


I then use Mark's LUA extensions in the SerialIO & WinLUAEx plugins to send data to my serial IR blaster:

function SendCommandToIRLinc (IRMsg)
--Set RTS
SERIAL_SetHandshaking("IRLinc", 2)
--Wait 20ms
TIME_Sleep(20)
--Send IR Command String
SERIAL_SendData("IRLinc", IRMsg)
--Drop RTS
SERIAL_SetHandshaking("IRLinc", 0)
--Wait Between Commands
--TIME_Sleep( 50 )
end


I know this isn't what you're doing, but, based on the fact that you understand programming, LUA may be the best way to go. Hope these examples help!!

By the way, do you ever get crashes using Portmon and Girder/Logger at the same time? My machine crashes consistently when I try to run both.

Good luck!

JimHugh
January 24th, 2003, 08:04 AM
Thanks for the tips Mike!

Learning LUA is on my list - the language itself is not hard, just trying to figure out the scoping and where you do things along with the interaction of Girder and plugins is the real challenge :wink:

Mark F
January 24th, 2003, 09:02 AM
One interesting thing is each successfully completed command ends in F4. There are other (non-successful) completion codes but keeping track of when a command completes will let you know when the F0 is the start of the next one.

Building a Serial Event script to process the responses from the DSS box should be do-able. Let me know if you get stuck. I'll be happy to help. :)

JimHugh
January 24th, 2003, 10:55 AM
Here is what I have come up with so far...

I am able to display the hex values and can parse the date substrings ok, but for now I'm stuck on converting the Hex to Decimal in Lua :oops:

What format template do I use? I'm using a string for now... But obviously decimal would be more natural for the WAF factor.

FYI, the DSSOSD event is a command that displays pld1 in the Simple OSD for now... I'll do more with it later.

No timeouts were necessary.

-- Transmit Script for RCA Serial - Hex->Bin Translate enabled
DSSLastCommand = SerialValue
DSSLastResponse = ""
SERIAL_SendData("RCA",DSSLastCommand)
-- End Transmit Script

-- Receive Script for RCA Serial - Bin->Hex Translate enabled

-- Channel
if DSSLastCommand == "FA07" then
DSSLastResponse = DSSLastResponse .. SerialValue
if strlen(DSSLastResponse) == 8 then
-- 00CC hex should be 204 decimal
DSSChannel = format ("%s", strsub(DSSLastResponse,3,6))
TriggerEvent("DSSOSD",203,DSSChannel)
end

-- Strength
elseif DSSLastCommand == "FA10" then
DSSLastResponse = DSSLastResponse .. SerialValue
if strlen(DSSLastResponse) == 6 then
-- 58 hex should be 88 decimal
DSSStrength = format ("%s", strsub(DSSLastResponse,3,4))
TriggerEvent("DSSOSD",203,DSSStrength)
DSSLastResponse = ""
end

-- DateTime
elseif DSSLastCommand == "FA11" then
DSSLastResponse = DSSLastResponse .. SerialValue
if strlen(DSSLastResponse) == 18 then
DSSDateTime = format ("%s", strsub(DSSLastResponse,5,14))
TriggerEvent("DSSOSD",203,DSSDateTime)
DSSLastResponse = ""
end

-- Ignore everything else
else
DSSLastResponse = ""
end

-- End Receive Script

Mark F
January 24th, 2003, 11:31 AM
You've been a very busy guy, haven't you? :D

Hex->Decimal in LUA is accomplished with the tonumber() function.


DecimalValue = tonumber(HexString, 16)

reworking these lines


-- 00CC hex should be 204 decimal
DSSChannel = format ("%s", strsub(DSSLastResponse,3,6))

into


-- 00CC hex should be 204 decimal
DSSChannel = format ("%d", tonumber(strsub(DSSLastResponse,3,6),16))

JimHugh
January 24th, 2003, 11:42 AM
Thanks for your help Mark!

I now have the channel and strength displaying correctly, just need to do the grunt work on the date/time parsing before I can upload the export group.

And to think I could have saved that weekend last fall rewriting DTVCon in VB when I could have just done it all with Girder and your serial plugin.

It took less time (and code!), even taking into account the Lua learning curve!

Mark F
January 24th, 2003, 12:20 PM
Cool! I'm glad you like it. :)

Incorperating LUA into Girder and directly supporting LUA scripts in the serial plugin has been essential to letting more people (like you!) help us support many different pieces of hardware. Once you export the device file (which will include the LUA event scripts), *you* will have written a plugin for the RCA DirectTV DSS Reciever. I think this is VERY cool but I'm a geek. :D

JimHugh
January 24th, 2003, 12:25 PM
I agree - this is cool! Couldn't have done it without your efforts though.

Thanks again! :o

Ron
January 24th, 2003, 12:58 PM
I've uploaded it to the serial settings page:

http://www.girder.nl/serial.php

If this is incorrect let me know.

JimHugh
January 24th, 2003, 01:04 PM
Thanks Ron,

That works for me... But where is the Serial page linked from?

I didn't even know it existed! :oops:

I just looked at the download link and it only references

Main Download
Plugins
Miscellaneous files

Ron
January 24th, 2003, 01:06 PM
It's a little hidden, that has to change indeed.

You could have found it if you clicked on the link of Mark's serial plugin (the house at the end of the line).

Mark F
January 24th, 2003, 01:08 PM
You have to go to the plugins page. At the right end of the Serial Port plugin table entry is a little house icon. Click that.

EDIT: I see Ron has added a link on the main download page. THANKS RON!!

JimHugh
January 24th, 2003, 04:28 PM
I just added a new Command to the GML file called DSSTUNE, it uses Lua to change the channel based on pld1.

So if the Eventstring is the Internet Event Server "DSSTUNE" the command would be:

event DSSTUNE 203 decimalchannel -silent

where decimalchannel is the channel to tune to

i.e. event DSSTUNE 203 204 -silent

If you don't want to download it again, here is the script:

LASTChannel = format("%04X", pld1)
TriggerEvent("DSSOSD", 203, "Changing to channel ", pld1 )
SERIAL_SendData("RCA", "FA46" .. LASTChannel )

I sent an updated zip file to Ron with the added command. Sorry I missed this obvious one!

JimHugh
April 9th, 2003, 05:32 PM
I just had a request to support multiple DSS Tuners... Here is the answer I provided.

The Girder Generic Serial Device Plugin allows a user to define a "NAME" for
the serial port, The benefit being that the actual COM port definition is in
Girder and not required to be known by triggering event.

So you could have RCA (the default) and RCA2 (or whatever) based on the
Setting in the .ini file when you import it.

[Device]
UserName=RCA

[Device]
UserName=RCA2

Then your events would be:

Event.exe DSSTUNE 203 301 RCA -silent
Event.exe DSSTUNE 203 204 RCA2 -silent

Change the Girder Variable Manipulation Script for DSSTune

From


DSSChannel = pld1
TriggerEvent("DSSOSD", 203, "Changing to channel ", DSSChannel )
DSSLastCommand = "FA46" .. format("%04X", DSSChannel)
SERIAL_SendData("RCA", DSSLastCommand )


To



DSSChannel = pld1
if pld2 == "" then
defaultdss = "RCA";
else
defaultdss = pld2;
end
print(defaultdss);
TriggerEvent("DSSOSD", 203, "Changing to channel ", DSSChannel )
DSSLastCommand = "FA46" .. format("%04X", DSSChannel)
SERIAL_SendData(defaultdss, DSSLastCommand )

riekl
October 8th, 2003, 05:39 AM
This plugin is great ! Only problem is i have a 6th gen receiver using the "new rca" code set, and wondering if support for this codeset can be added to this plugin somehow ?

JimHugh
October 8th, 2003, 08:19 PM
I tried to make one from the docs and posted it at http://www.hughestechnology.com/jim/HomeTheater/Girder/RCA%20DirectTV%20DSS%20RG%20New%20Commands.zip

I don't have a newer unit to test it with so I would appreciate any feedback as to what works/doesn't work.

You could always look at the send strings from DTVCon and modify the existing group as necessary, I'm sure others would appreciate your efforts if you tested it and sent it to Ron for posting.

orangeblood
December 4th, 2003, 05:54 AM
I've got an RCA DRD430RG 6th generation Sat box and I've almost got this plugin working. (Many thanks, Jim) Some of the commands in the new code GML still needed to have "FA46" changed to "FAA6", but after doing so all of the basic commands, such as Channel +/-, work great.

I have run into one problem with the DSSTune command that I've been unable to fix on my own. I'm using myHTPC to trigger the command and I know the payload is getting to Girder because the OSD displays "Changing to channel xxx" but the channel never changes. I think I've tracked the problem to the serial command not having the extra pair of "FF"s my box requires. For example, if I want to tune to channel 206, DSSLastCommand is populated with "FAA600CE" but for my Sat box to accept the command I need "FAA600CEFFFF". Anyone have a guess as to how to fix this?

Thanks.

JimHugh
December 4th, 2003, 05:59 AM
Change the Girder Variable Manipulation Script for DSSTune



from
DSSLastCommand = "FA46" .. format("%04X", DSSChannel)
to
DSSLastCommand = "FA46" .. format("%04X", DSSChannel) .. "FFFF"

orangeblood
December 4th, 2003, 11:45 AM
That did the trick, I'd left off the ".." when I tried before. Everything seems to be working now. I also inserted a "DSSON" event before the OSD to make sure the receiver is turned on. Seems to be working properly as well.

Thanks again for the plugin and the help.

orangeblood
January 17th, 2004, 02:31 PM
Jim,

Could you help me with one more task? By using myHTPC I've been able to combine my local broadcast and DirecTV program guides into one listing. MyHTPC knows whether to switch between the tuner and S-video input by the name of the channel. However, the DSSTune command is issued to the sat box even when I change between local channels. I think I can get around this with a simple IF statement in the Girder command, but I'm not sure how to modify the script. Local channels are tyically 02, 06, etc. whereas DTV channels are SVID-202, SVID-204, etc. Would it be possible to make an IF statement that looks at the first few characters of the pld1 payload to see if they are "SVID-" and to cancel the command if they are not?

Thanks.

vsrini31
April 1st, 2004, 10:17 PM
Has anyone got a plugin for transmitting IR codes to a Dishnet receiver? Appreciate your reply. Thanks!

Promixis
April 2nd, 2004, 05:09 AM
Has anyone got a plugin for transmitting IR codes to a Dishnet receiver? Appreciate your reply. Thanks!

Do you want to send IR or serial commands?

DaMan0007
January 9th, 2006, 11:48 PM
I am attempting to do the exact opposite of what this tread talks about. I have a Tivo and I want it to send channel numbers to the computer using the serial port. I know that the Tivo will send a power on signal of "FA02". I then want to send an ok signal of "F0F4" using girder. Then it will send a ok to receive signal of "FA46" and again I need to send the "F0F4" response. It will then send the hex channel number that will need to be translated in to dec. I am sure this can be done using lua and girder but me not being a programmer and new to this program I feel it could take me months to figure this out on my own. I am hoping someone on this forum will shed some light on my task. Thanks

:D

Promixis
January 10th, 2006, 04:54 AM
I am attempting to do the exact opposite of what this tread talks about. I have a Tivo and I want it to send channel numbers to the computer using the serial port. I know that the Tivo will send a power on signal of "FA02". I then want to send an ok signal of "F0F4" using girder. Then it will send a ok to receive signal of "FA46" and again I need to send the "F0F4" response. It will then send the hex channel number that will need to be translated in to dec. I am sure this can be done using lua and girder but me not being a programmer and new to this program I feel it could take me months to figure this out on my own. I am hoping someone on this forum will shed some light on my task. Thanks

:D

do you have girder talking to the tivo yet?

DaMan0007
January 10th, 2006, 09:21 AM
I can use Hex com tool to talk to the tivo. I also have the serial plugin working so it talks to the tivo. The logging program shows all the commands sent from the tivo but I am a little lost as to how to get the scripts to work. I have read through several topics on rs-232 communications but I am not sure where the scripts should go or even where to begin.

Promixis
January 10th, 2006, 12:43 PM
Its a little complicated :(

The serial file should help somewhat. You can process the the response from the tivo in the serial receive definition.

DaMan0007
January 10th, 2006, 10:50 PM
ok I wrote some code to try to send data back to the tivo but I seems to have hung the plugin or something because I don't get any logging when it's in place. Here is what I put in the receive script section of the tivo serial object.



test = "F0F4"
if pld1 == "FA02" then
SERIAL_SendData(Tivo.DeviceName, test)
end


Does anyone have some pointers or a thread I should checkout. Thanks :)

Promixis
January 11th, 2006, 05:15 AM
that looks about right.

I haven't used the g3.3 stuff for so long that I don't have much help to offer... :(

The collection of g3.3 serial device files may offer some ideas.