SONY 232
jackygross
Junior Member
Anyone has a sample of how to use the 232 KDL protocol?
I'm not familiar with the checksum method
trying to control power on/off
input switching
Aspect modes
Help is greatly appreciate it
thanks
I'm not familiar with the checksum method
trying to control power on/off
input switching
Aspect modes
Help is greatly appreciate it
thanks
Comments
-
I don't have anything written for the KDL series, but from the protocol documentation it seems that the checksum is just the sum of the values of the data being sent. If the total is greater than $ff, then only the last byte is used, e.g. if the data adds up to $01FF then the checksum would be $FF. You can try the following to control the device:
DEFINE_DEVICE dvTelevision = 5001:1:0 dvTP = 10001:1:0 DEFINE_CONSTANT INTEGER nTPButtons[] = { 81, //Video 1 82, //Video 2 83, //Video 3 84, //Component 1 85, //Component 2 86, //HDMI 1 87, //HDMI 2 88, //HDMI 3 89, //HDMI 4 90 // PC } DEFINE_EVENT DATA_EVENT[dvTelevision] { ONLINE: { SEND_COMMAND dvTelevision,'SET BAUD 9600,N,8,1' } } BUTTON_EVENT[dvTP,nTPButtons] { PUSH: { STACK_VAR INTEGER nButtonPressed nButtonPressed=GET_LAST(nTPButtons) SWITCH (nButtonPressed) { CASE 1: SEND_STRING dvTelevision, "$8c,$00,$02,$03,$02,$01,$03" //(*$8C = STX, $00 = Category (always $00 for this device), $02 = command for "Input Select", $03 = Length of Data to follow including checksum (3 bytes in this case), $02 = "Video", $01 = "#1 input", $03 = $02+$01) CASE 2: SEND_STRING dvTelevision, "$8c,$00,$02,$03,$02,$02,$04" CASE 3: SEND_STRING dvTelevision, "$8c,$00,$02,$03,$02,$03,$05" CASE 4: SEND_STRING dvTelevision, "$8c,$00,$02,$03,$03,$01,$04" CASE 5: SEND_STRING dvTelevision, "$8c,$00,$02,$03,$03,$02,$05" CASE 6: SEND_STRING dvTelevision, "$8c,$00,$02,$03,$04,$01,$05" CASE 7: SEND_STRING dvTelevision, "$8c,$00,$02,$03,$04,$02,$06" CASE 8: SEND_STRING dvTelevision, "$8c,$00,$02,$03,$04,$03,$07" CASE 9: SEND_STRING dvTelevision, "$8c,$00,$02,$03,$04,$04,$08" CASE 10: SEND_STRING dvTelevision, "$8c,$00,$02,$03,$05,$01,$06" } } }
I'm confident that this would work. If someone else has a functioning code block hopefully they'll post it for you but this should get you started in the meantime.
--John -
I just put an XBR5 in a system I'm working on the other day. I could not get it to work with "Control a Device." As soon as I dropped the codes into a program, everything worked. Not sure if this is your problem.
Here's the code I'm using, you can just drop this in an include file (the Structure for the Sony vars is not defined here) and reference the channel event for on/off:DEFINE_VARIABLE CHAR sSonyXBR5_Header[] = {$8C,$00} CHAR sSonyXBR5_Function[] = {$00,$01,$02} CHAR sSonyXBR5_Length CHAR sSonyXBR5_Cmd[] = {$00,$01,$02,$03,$04,$05} CHAR sSonyXBR5_Checksum INTEGER nHeaderPos CHAR sSonyXBR5_NewCmd[20] PERSISTENT _Display stSonyXBR5 DEFINE_FUNCTION fnSonyXBR5MsgBuild(INTEGER nArgFunc, INTEGER nArgState, INTEGER nArgSub) {// Funcs 1=power,2=enable,3=inputs,4=channel,5=volume,6=muting STACK_VAR CHAR sMyLength STACK_VAR CHAR sMyData1 STACK_VAR CHAR sMyData2 STACK_VAR CHAR sMyMsg[20] STACK_VAR CHAR sMyCheckSum SWITCH(nArgFunc) { CASE 1: // power { sMyLength = $02 sMyData1 = sSonyXBR5_Cmd[nArgState+1] } CASE 2: // enable { sMyLength = $02 sMyData1 = sSonyXBR5_Cmd[nArgState+1] } CASE 3: // input { IF(nArgState<=2) // length is two { sMyLength = $02 sMyData1 = sSonyXBR5_Cmd[nArgState+1] } ELSE { sMyLength = $03 sMyData1 = sSonyXBR5_Cmd[nArgState+1] sMyData2 = sSonyXBR5_Cmd[nArgSub] } // add rest of funcs! } } // Build string sMyMsg = "sSonyXBR5_Header,sSonyXBR5_Function[nArgFunc],sMyLength,sMyData1" sMyChecksum = fnSonyXBR5CheckSum(sMyMsg) stSonyXBR5.TxBuf = "stSonyXBR5.TxBuf,sMyMsg,sMyChecksum" } DEFINE_FUNCTION CHAR fnSonyXBR5CheckSum(CHAR sArgCmd[]) { STACK_VAR CHAR sCheckSum STACK_VAR INTEGER nLength STACK_VAR INTEGER nCount nLength = LENGTH_STRING(sArgCmd) FOR(nCount=1;nCount<=nLength;nCount++) { sCheckSum = sCheckSum+sArgCmd[nCount] } RETURN sCheckSum; } DEFINE_FUNCTION INTEGER fnSonyXBR5AckParse(CHAR sArgAck) { STACK_VAR INTEGER nMyReturn SWITCH(sArgAck) { CASE $00: { nMyReturn=1 } CASE $01: // data too high { nMyReturn=0 } CASE $02: // data too low { nMyReturn=0 } CASE $03: // command canceled { nMyReturn=0 } CASE $04: // error { nMyReturn=0 } } RETURN nMyReturn; } DEFINE_EVENT DATA_EVENT[dvXBR5] { ONLINE: { SEND_COMMAND DATA.DEVICE,'SET BAUD 9600, N, 8, 1, 485 DISABLE' SEND_COMMAND DATA.DEVICE,'RXON' SEND_COMMAND DATA.DEVICE,'HSOFF' SEND_COMMAND DATA.DEVICE,'XOFF' } STRING: { WHILE(LENGTH_STRING(stSonyXBR5.RxBuf)) { IF(GET_BUFFER_CHAR(stSonyXBR5.RxBuf)=$70) { IF(fnSonyXBR5AckParse(GET_BUFFER_CHAR(stSonyXBR5.RxBuf))) { // command acknowledged ON[stSonyXBR5.CTS] GET_BUFFER_CHAR(stSonyXBR5.RxBuf) // remove the checksum } ELSE { // something went wrong } } ELSE { // not the beginning of the response string } } } } CHANNEL_EVENT[dvXBR5,255] // power cmd and fb { ON:{fnSonyXBR5MsgBuild(1,1,0)} OFF:{fnSonyXBR5MsgBuild(1,0,0)} } DEFINE_PROGRAM IF(LENGTH_STRING(stSonyXBR5.TxBuf) && stSonyXBR5.CTS) // stuff in the buffer and clear to send { OFF[stSonyXBR5.CTS] // cancel related waits CANCEL_WAIT 'Cancel SonyXBR5 CTS' nHeaderPos = FIND_STRING(stSonyXBR5.TxBuf,$8C,2)-1 SEND_STRING dvXBR5,REMOVE_STRING(stSonyXBR5.TxBuf,LEFT_STRING(stSonyXBR5.TxBuf,nHeaderPos),1) } ELSE IF(!LENGTH_STRING(stSonyXBR5.TxBuf) && stSonyXBR5.CTS) // nothing in buffer and clear to send { // poll? } ELSE IF(!stSonyXBR5.CTS) // not clear to send { WAIT 25 'Cancel SonyXBR5 CTS' { ON[stSonyXBR5.CTS] } } -
What was the pin-out of the cable that you used to control the Sony KDL display?
-
Sony_Command[1]= "$8C,$00,$00,$02,$01,$8F" //PON
Sony_Command[2]= "$8C,$00,$00,$02,$00,$8E" //POF
Sony_Command[3]= "$8C,$00,$01,$02,$01,$90" //Standby ON
Sony_Command[4]= "$8C,$00,$01,$02,$00,$8F" //Standby OFF
Sony_Command[5]= "$8C,$00,$02,$03,$05,$01,$97" //RB1
Sony_Command[7]= "$8C,$00,$02,$03,$02,$01,$94" //VID1
Sony_Command[8]= "$8C,$00,$02,$03,$02,$02,$95" //VID2
Sony_Command[9]= "$8C,$00,$02,$03,$02,$03,$96" //VID3
You need to send standby on before turning off the KDL or you will not be able to turn it back on. -
The check sum is just an addition of all the bytes and take the least significant byte.
$FF + $FF = $01,$FE $FE is the least significant byte. -
What is the cable pin-out that you used?
-
Nothing weird. I'm working remotely so I wasn't onsite. 2,3,5 The manual says 2 is RX 3 is TX and 5 is GND for the Sony. So swap 2 and 3.
-
Of course the Display should be ON when you begin to test the code because the KDL will never be in a Standby ON state until the command is sent when the display is on.
-
If you're using checksums and you don't want to have to do the math, here's a checksum calculating function I stole off this forum a while back. No idea who to credit it to, but its useful
define_function integer calcchecksum(char cMsg[]) { stack_var integer nLoop stack_var integer nCheckSum off[nCheckSum] for (nLoop=1;nLoop<=length_string(cMsg);nLoop++) { nCheckSum=((nCheckSum+cMsg[nLoop])& $FF) } return nCheckSum }
J -
I'm convinced that 232 control of the Sony KDL units is problematic. The code and cable seem to be very straight-forward, but I've had no success and we've given up, moving to IR control with discrete ON/OFF/INPUT (http://www.remotecentral.com/cgi-bin/files/rcfiles.cgi?area=pronto&db=discrete&br=sony&dv=television).
I post this reply so that others do not waste as much time on this as I have. -
Keep in mind that a large amount of KDL XBR5's were shipped with wrong firmware making the 232 port useless. I'm not too sure of the cut off date when Sony fixed the problem. Probably last November.
-
That was the key piece of information that I wasn't aware of, and am not surprised to hear. Thanks for that. Any hints on acquiring the new firmware, so that others who may read this post can use?
-
Feb 2008 is the cutoff date and the firmware is only available from Sony.
Leave a Comment
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums
