Jump to content

Control A LCD Projector via a Telnet Session


Recommended Posts

Hello, :)

I am a newbie to the world of "AutoIt", and could use some help.

I am a AMX control system programmer. AMX is a company that builds hardware for controlling audio and video equipment via differant control methods. The control language is very similiar to C++ but with its own differances.

I want to create an app with AutoIt to control a LCD projector via a telnet seesion. This projector will only accept data in the form of HEX strings. An example is as follows:

"$BE,$EF,$03,$06,$00,$BA,$D2,$01,$00,$00,$60,$01,$00"; (Note: the "$" is an identifer that the byte is in HEX)

This is a command to turn on the projector. In the past, I use to do this via a RS-232 connection, but now that more and more projectors are providing an ethernet interface, I am starting to move control via that method.

I have controlled this projector using a third part app to send HEX strings through a TELNET session but would like to create a GUI based application in which I can press a button, and it will send the designated HEX string to the projector.

What I need is a basic script that I can use as a reference to create this app.

Can anyone out there please help me out.

Thank you for your time and consideration on this matter. :whistle:

Link to comment
Share on other sites

I want to create an app with AutoIt to control a LCD projector via a telnet seesion. This projector will only accept data in the form of HEX strings. An example is as follows:

is it a real telnet session (telnet protocol, user login, etc.) or just a TCP connect to a special port?

If telnet see here: http://www.autoitscript.com/forum/index.ph...8&hl=telnet

Otherwise see the help file samples for TCPSend() and the other TCP functions.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Thanks for responding, :)

This particular LCD projector does use an actual telnet session (port 23) to control it. I want to create a GUI app that can send pre-define HEX strings to the projector.

I don't want to use a 3rd party telnet app that I can send arguments to, to control this device. Like I had mention earlier, I have never written an AutoIT app so I am looking for a helpful starting point to begin this particular project.

Anyone out there willing help.

Thanks all.......... :whistle:

Link to comment
Share on other sites

This particular LCD projector does use an actual telnet session (port 23) to control it. I want to create a GUI app that can send pre-define HEX strings to the projector.

You did not answer my question. Do you have to authenticate when you telnet to port 23? Can you sniff the session with wireshark (www.wireshark.org) and post the capture file, so we can see the communication. Maybe you can just use TCPSend() to send your commands.

I don't want to use a 3rd party telnet app that I can send arguments to, to control this device. Like I had mention earlier, I have never written an AutoIT app so I am looking for a helpful starting point to begin this particular project.

Did you read the other thread? The argument was, that it's easier to send real telnet commands via an external tool than with the built-in windows telnet command.

I guess it would be possible to emulate the whole telnet protocol with the AutoIT TCP functions, but that's a lot of work...

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Ok,

All is moving ahead, but I need one last bit of help. The following AutoIT script works to control this particular model projector

#include <GUIConstants.au3>
#include <String.au3>

TCPStartup()

$VPROJ_IP = "192.168.0.199"
$TCP_PORT = "23"

$GOOEY = GUICreate("3M Projector Control",320,240)
$edit = GUICtrlCreateEdit("",16,120,272,72,$WS_DISABLED)
$input = GUICtrlCreateInput("",8,8,112,21)
$inpPORT = GUICtrlCreateInput("",128,8,56,21)
$butt = GUICtrlCreateButton("Send",192,8,72,24,$BS_DEFPUSHBUTTON)
$btnON = GUICtrlCreateButton("ON",16,48,72,24,$BS_DEFPUSHBUTTON)
$btnOFF = GUICtrlCreateButton("OFF",16,80,72,24,$BS_DEFPUSHBUTTON)
$btnRGB = GUICtrlCreateButton("RGBHV",96,48,72,24,$BS_DEFPUSHBUTTON)
$btnVID = GUICtrlCreateButton("VIDEO",96,80,72,24,$BS_DEFPUSHBUTTON)
GUISetState()



Dim $ConnectedSocket = -1
$ConnectedSocket = TCPConnect($VPROJ_IP , $TCP_PORT)

Dim $msg, $recv, $ret
;==============================================
While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

;;; send part:
    
        If $msg = $btnON Then
            $ret = TCPSend( $ConnectedSocket ,chr(190)&chr(239)&chr(03)&chr(06)&chr(00)&chr(186)&chr(210)&chr(01)&chr(00)&chr(00)&chr(96)&chr(01)&chr(00))  
        
        ElseIf $msg = $btnOFF Then
            $ret = TCPSend( $ConnectedSocket ,chr(190)&chr(239)&chr(03)&chr(06)&chr(00)&chr(42)&chr(211)&chr(01)&chr(00)&chr(00)&chr(96)&chr(00)&chr(00))
            
        ElseIf $msg = $btnRGB Then
            $ret = TCPSend( $ConnectedSocket ,chr(190)&chr(239)&chr(03)&chr(06)&chr(00)&chr(254)&chr(210)&chr(01)&chr(00)&chr(00)&chr(32)&chr(00)&chr(00))
            
        ElseIf $msg = $btnVID Then
            $ret = TCPSend( $ConnectedSocket ,chr(190)&chr(239)&chr(03)&chr(06)&chr(00)&chr(110)&chr(211)&chr(01)&chr(00)&chr(00)&chr(32)&chr(01)&chr(00))
            
        ;If @ERROR Or $ret < 0 Then ExitLoop
    GUICtrlSetData($input,"")
    GUICtrlSetState($input,$GUI_FOCUS)
   EndIf


;;; receive part:

    $recv = TCPRecv( $ConnectedSocket, 23)
    If @error Then ExitLoop
    If $recv <> "" Then GUICtrlSetData($edit, " > " & _StringToHex($recv) & @CRLF & GUICtrlRead($edit))
    ;GUICtrlSendMsg($edit, $EM_SCROLL, $SB_PAGEDOWN, 0)
   
WEnd



quit()


func quit()
    TCPCloseSocket( $ConnectedSocket )
    TCPShutdown()
    Exit
endfunc

The problem is that, in experimenting, I could send hex strings but I had to do it by converting a "DEC" to a HEX byte by using the chr() function.

I would like to send the string to the TCP port as HEX with out having to do it via a function. Can anyone help.

Thank you.... :whistle:

Link to comment
Share on other sites

Hex()? In the help file...

I guess he is rather looking for _StringToHex()

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

To Those AutoIt Programmers, :)

I tried both solutions, but it is not giving me the results i need. When I do a test by connecting to an external processor, the strings I am receiving are ASCII. I need to be sending HEX because some devices use non-printable characters.

In the example code, by coverting each DEC value, I am able to send the non-printable ASCII characters.

The HEX string I need to send via a TCP connection is this:

0xBE 0xEF 0x03 0x06 0x00 0xBA 0xD2 0x01 0x00 0x00 0x60 0x01 0x00

This represents the "Power On" command for this projector.

So, my question is this --- How do I send this string out without having to do the following:

1. Cross Reference the HEX value to the DEC value

2. Use the chr() function to take the DEC value to convert it to HEX (if this is what it is acctually doing.)

3. Send it as a byte for byte stream.

Like I said earlier, this works. But I don't want to have to do this each time.

Thanks to all how have been respondiing to this POST.

PS. I understand that, in the end, it is all 11111's and 00000's acctually being sent. :whistle:

Edited by DigiMe
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...