FiveWin + Com Port with Terminal Server

Post Reply
ali
Posts: 23
Joined: Wed May 07, 2008 2:50 pm
Location: Austria

FiveWin + Com Port with Terminal Server

Post by ali »

Hi People!

Do somebody work with Windows Terminal Server + FiveWin + COM Port redirection?

I have edit a litte sample Programm from Enrico. That read the Com Port imput. On a Local Machine it works fine but on a Terminal Server I get no DATA. With a other Programm (no FW) it works. I hope someone can help me.

Here the source:

Code: Select all

// Working sample of a simple ASCII terminal program - Developed by Enrico M. Giordano

#include "Fivewin.ch" 

FUNCTION MAIN() 

    LOCAL oDlg 

    LOCAL oGet, cTxt := "" 

    LOCAL nCom 

    DEFINE DIALOG oDlg; 
           SIZE 500, 500; 
           TITLE "Terminale" 

    @ 0, 0 GET oGet VAR cTxt MEMO READONLY 

    oGet:bKeyDown = { | nKey | Tasti( nCom, nKey ) } 

    ACTIVATE DIALOG oDlg; 
             ON INIT ( oGet:AdjClient(),; 
                       nCom := APRICOM( oDlg, oGet ),; 
                       IF( nCom < 0, oDlg:End(), ) ); 
             CENTER 

    IF nCom >= 0; CLOSECOMM( nCom ); ENDIF 

    RETURN NIL 


STATIC FUNCTION TASTI( nCom, nKey ) 

    SENDSTR( nCom, CHR( nKey ) ) 

    RETURN NIL 


STATIC FUNCTION APRICOM( oDlg, oGet ) 

    LOCAL nCom, cDcb 

    BEGIN SEQUENCE 
        nCom = OPENCOMM( "COM1", 2048, 128 ) 

        IF nCom < 0 
            ? "Errore di apertura della porta di comunicazione." 
            BREAK 
        ENDIF 

        BUILDCOMMDCB( "COM1:9600,N,8,1", @cDcb ) 

        IF !SETCOMMSTATE( nCom, cDcb ) 
            ? "Errore di impostazione della porta di comunicazione." 
            BREAK 
        ENDIF 

        oDlg:bCommNotify = { | nCom | Connect( nCom, oGet ),; 
                                      EnableCommNotification( nCom, oDlg:hWnd, 1, -1 ) } 

        IF !ENABLECOMMNOTIFICATION( nCom, oDlg:hWnd, 1, -1 ) 
            ? "Errore di abilitazione della notifica." 
            BREAK 
        ENDIF 
    RECOVER 
        nCom = -1 
    END SEQUENCE 

    RETURN nCom 


STATIC FUNCTION CONNECT( nCom, oGet ) 

    LOCAL cStr 

    ENABLECOMMNOTIFICATION( nCom, 0, 1, -1 ) 

    cStr = RECEIVESTR( nCom ) 

    cStr = STRTRAN( cStr, CHR( 13 ), "" ) 
    cStr = STRTRAN( cStr, CHR( 10 ), CRLF ) 

    oGet:Append( cStr ) 

    RETURN NIL 


STATIC FUNCTION SENDSTR( nCom, cString ) 

    LOCAL nBytes := WRITECOMM( nCom, cString ) 

    RETURN nBytes = LEN( cString ) 


STATIC FUNCTION RECEIVESTR( nCom ) 

    LOCAL cBuf := SPACE( 1000 ) 

    RETURN LEFT( cBuf, READCOMM( nCom, @cBuf ) )
 
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: FiveWin + Com Port with Terminal Server

Post by Enrico Maria Giordano »

Are you sure that com port is COM1 on terminal server? And, anyway, do you get one of the error messages that are in the sample? Or any other error message?

EMG
ali
Posts: 23
Joined: Wed May 07, 2008 2:50 pm
Location: Austria

Re: FiveWin + Com Port with Terminal Server

Post by ali »

Hi!

With the no FW Program I get data from COM 1. The Port is correct. No error messages. nothing happend. Is it possible to set the timer to receiving Data up to give the Prog. more time?

Best regards

Aljoscha
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: FiveWin + Com Port with Terminal Server

Post by Enrico Maria Giordano »

A timer is needed only for polling technique not for the better interrupt technique that my sample uses.

EMG
Post Reply