Announcement

Collapse
No announcement yet.

Problem with rs232 communication

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with rs232 communication

    I have 4-Source 4-Zone Equipment Rack Hub (DIGI-5 D5RH) from xantech
    (http://www.xantech.com/Video/AVDistr...n/DIGI-5/D5RH/

    #2
    I would add a callback script/subroutine and just output any reply you get from the device to the log, just to check whether the serial port was talking to it correctly.

    Also have you confirmed that any other programs are able to talk to it? Just to eliminate hardware...

    Comment


      #3
      Thank you!

      I agree with you, but I'm not sure how to write a callback script.
      It is the same with query.
      Can you make a sample?

      Comment


        #4
        Originally posted by koyvindh View Post
        Thank you!

        I agree with you, but I'm not sure how to write a callback script.
        It is the same with query.
        Can you make a sample?
        I'm going from memory here but where you have this line;

        e=hs.OpenComPort(4,"9600,n,8,1",1,"","")

        change it to

        e=hs.OpenComPort(4,"9600,n,8,1",1,"sertest.txt","main")

        then have another script called 'sertest.txt' with this in it;

        Code:
        sub main(parms)
        hs.writelog "serial", parms
        end sub
        I am hoping that the device sends back a command when you send absolutely anything to it.

        Comment


          #5
          This is from a vbs script that I use for controlling my Denon. You might get some clues from it.

          PHP Code:
          'Control for Denon Receiver
          '

          Const PortNum 5
          Sub Main
          ()
              
          errMsg hs.OpenComPort(PortNum,"9600,n,8,1",1,"denon.vbs","Receive",vbCr)
              If 
          errMsg <> "" Then 
                  hs
          .writelog "Denon.vbs","Error opening COM" PortNum " : " errMsg
              
          Else
                  
          hs.writelog "Denon.vbs","Success opening COM " PortNum ". Talking to Denon Receiver"
              
          End if
          End Sub 'Main

          Sub Send(command)
              '
          ============================ S E N D I N G   C O M M A N D S  =============================================
              
          'Remember what command was issued if there is a data that is comming back
              Const LastCommand = "DenonCommand"
              hs.createVar LastCommand
              hs.saveVar LastCommand, parm
              
              '
          Issue the command
              Select 
          Case ucase(command)
                  Case 
          "OFF"
                      
          hs.SendToComPort PortNum,"PWSTANDBY" Chr(13) & Chr(10)
                      
          hs.writelog "Denon.vbs","Sending command OFF " 
                      
          hs.ExecX10 "v6""off",0,0
                  
          Case "ON"
                      
          hs.SendToComPort PortNum,"PWON" Chr(13) & Chr(10)
                      
          hs.writelog "Denon.vbs","Sending command ON " 
                      
          hs.ExecX10 "v6""on",0,0
                  
          'Case "TV"
                      '
          hs.SendToComPort PortNum"SITV", & Chr(13) & Chr(10)
                  Case Else
                      
          hs.SendToComPort PortNum,command  Chr(13) & Chr(10)
                      
          hs.writelog "Denon.vbs","Denon attempting to send command " command " to receiver at COM" PortNum
              End Select
          End sub

          Sub Receive
          (strBack)    '======================= R E C E I V I N G    C O M M A N D S ==========================
              CommandIssued = hs.GetVar(LastCommand)
              hs.SetDeviceString "v70",strBack,True
              hs.writelog "denon.vbs","Denon Receiving Data ------> " & strBack
              If strBack = "PWSTANDBY" Then 
                  '
          hs.SetDeviceString "v6","Standby"
                  
          hs.SetDeviceStatus "v6",3
                  
          'hs.SetDeviceString "v6", "<img src=/images/homeseer/off.gif>Standby"
              End if
              If strBack = "PWON" Then
                  hs.SetDeviceStatus "v6",2
                  '
          hs.SetDeviceString "v6""<img src=/images/homeseer/on.gif>On"
              
          End if
              
          '==============================  XM Radio Stuff ========================================
              If INStr(strBack,"TFXM") > 0 Then
                  tag = "TFXM"
                  PullData(Replace(strBack,tag,""))
              End if
              '
          ===========================  Input Selection  ======================================================================
              If 
          InStr(strBack,"SI") > 0 Then
                  Select 
          Case strBack
                      
          Case "SITV"
                          
          hs.SetDeviceString "v7","Satellite",True
                      
          Case "SIDVD"
                          
          hs.SetDeviceString "v7","DVD",True
                      
          Case "SIPHONO"
                          
          hs.SetDeviceString "v7","Phonograph",True
                      
          Case "SICD"
                          
          hs.SetDeviceString "v7","CD",True
                      
          Case "SITUNER"
                          
          hs.SetDeviceString "v7","Tuner",True
                      
          Case "SIVCR-1"
                          
          hs.SetDeviceString "v7","VCR-1",True
                      
          Case "SIVCR-2"
                          
          hs.SetDeviceString "v7","VCR-2",True
                      
          Case "SIV.AUX"
                          
          hs.SetDeviceString "v7","AUX",True
                      
          Case Else
                          
          hs.SetDeviceString "v7","UNK",True
                          hs
          .writelog "Denon.vbs","ERROR. Unknown Input Source " strBack
                  End Select
              End 
          if
              If 
          InStr(strBack,"MV") > 0 Then
                  volume 
          Mid(strBack,3,Len(strBack))
                  
          hs.SetDeviceString "v8","Master VOL " volume,True
              End 
          if
              If 
          InStr(strBack,"MU") > 0 Then
                  mute 
          Mid(strBack,3,Len(strBack))
                  
          hs.setDeviceString "v9","Mute " mute,True
              End 
          if
              
          ' ----------- Zone 2 Stuff
              If InStr(strBack,"Z2") > 0 Then
                  ' 
          ------------- New Sutff ----------------------------------

                  If 
          InStr(strBack,"Z2TUNER") > 0 Then hs.SetDeviceString "V12","Zone 2 Source Tuner"True

                  
          '------- ------ New Sutff ----------------------------------
                  Z2Vol = Mid(strBack,3,Len(strBack))
                  hs.SetDeviceString "v10","Zone2 VOL " & Z2Vol, True
              End if
          End sub 
          Don

          Comment

          Working...
          X