Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #5205 > unrolled thread

Question for Ginny

Started byMartin <spam@spam.spam>
First post2013-05-08 12:04 +0100
Last post2013-05-10 14:16 +0100
Articles 4 — 2 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Question for Ginny Martin <spam@spam.spam> - 2013-05-08 12:04 +0100
    Re: Question for Ginny Martin <spam@spam.spam> - 2013-05-08 12:15 +0100
      Re: Question for Ginny "Ginny Caughey" <gcaughey@online.hotmail.com> - 2013-05-09 07:13 -0400
        Re: Question for Ginny Martin <spam@spam.spam> - 2013-05-10 14:16 +0100

#5205 — Question for Ginny

FromMartin <spam@spam.spam>
Date2013-05-08 12:04 +0100
SubjectQuestion for Ginny
Message-ID<Riqit.30557$a77.23623@fx18.fr7>
Hello Ginny

I am testing out your comms library

Your sample does not error. But my code (based on yours) is getting 
error 87 SetCommState failed in SetProtcol. tested on 2 different PCs.

I am setting up the serial in a method then passing it back to the screen.

Any ideas please?

Thanks

Martin

METHOD StartComms	(nPort)			CLASS ScannerScreen

LOCAL oComm	AS Serial, ;
       oMain	AS MainWindow, ;
       nBaud	AS DWORD, ;
       nPar	AS BYTE, ;
       nLen	AS BYTE, ;
       nStop	AS BYTE, ;
       cErr	AS STRING, ;
       cPort	AS STRING, ;
       oComI	AS ComINI

cPort	:= 'Com'+Str(nPort,1)


oMain	:= SysObject()
oComI	:= oMain:ComINIFS

oComm	:= Serial{SELF:Handle()}
oComm:Open(cPort)
DO CASE
	CASE nPort = 1
		nBaud	:= oComI:Com1Baud
		nPar	:= oComI:Com1Par
		nLen	:= oComI:Com1Len
		nStop	:= oComI:Com1Stop
	CASE nPort = 2
.............
.............
ENDCASE

oComm:Baud		:= nBaud
oComm:Parity	:= nPar
oComm:ByteSize	:= nLen
oComm:StopBits	:= nStop

IF !oComm:SetProtocol()
	cErr	:= oComm:ErrorDesc
	Hit_Key('Unable to open '+cPort+CRLF+;
			'Error Text '+oComm:ErrorDesc+CRLF+;
			'Error Code '+oComm:ErrorCode,'Communication Setup Error')

	oComm:Close()
	BREAK
ENDIF
// Start receiving comm events in the MLE
oComm:EnableEvents(EV_RXCHAR)

RETURN oComm

[toc] | [next] | [standalone]


#5206

FromMartin <spam@spam.spam>
Date2013-05-08 12:15 +0100
Message-ID<Lsqit.23306$sr.21245@fx09.fr7>
In reply to#5205
This line causes the error
oComm:StopBits	:= nStop

nStop is a byte with a value of 1

Looks like one stop bit is 0!

Aghhhhhhhhhh!!!!!!!!!!!!

[toc] | [prev] | [next] | [standalone]


#5210

From"Ginny Caughey" <gcaughey@online.hotmail.com>
Date2013-05-09 07:13 -0400
Message-ID<518b84d2$0$31538$c3e8da3$cc4fe22d@news.astraweb.com>
In reply to#5206
Stopbits are a bit strange. Here's code from my serial tester that works:

oDevice:StopBits := IIF(oCCZeroButton:Checked, 0, 2)

Let me know if you need my tester code. It uses ClassMate but I'm including 
the BeginButton code here so you can see how it works:

METHOD BeginButton() CLASS CommWindow
    LOCAL cErr AS STRING
    LOCAL dwBaud, dwParity AS DWORD
    LOCAL cPort AS STRING
    LOCAL oDevice AS Serial

    oDevice := oDCCommEdit:Device

    // Set the comm MLE to empty again
    oDCCommEdit:TextValue := ""
    oDCCommEdit:SetFocus()

    BEGIN SEQUENCE
        // Set comm port with values from the window's controls
        cPort := oDCPortListBox:CurrentItem
        IF !oDevice:Open(cPort)
            cErr := "Cannot open port "+oDCPortListBox:CurrentItem + CRLF+ ;
                "Error code "+oDevice:ErrorCode+": "+oDevice:ErrorDesc
            BREAK
        ENDIF

        // Set timeout values for read
        //oDCCommEdit:Device:ReadIntervalTimeout := MAXDWORD
        oDevice:ReadIntervalTimeout := 0    // Disable read interval 
timeouts
        oDevice:ReadTimeoutMultiplier := 500
        oDevice:ReadTimeoutConstant := 1000
        oDevice:WriteTimeoutMultiplier := 0
        oDevice:WriteTimeoutConstant := 1000
        IF !oDevice:SetTimeOut()
            cErr := "Can't set timeout values for scale port"
            BREAK
        ENDIF

        dwBaud := Val(oDCBaudListBox:CurrentItem)
        oDevice:Baud := dwBaud
        dwParity := oDCParityListBox:CurrentItemValue
        oDevice:Parity := dwParity
        oDevice:ByteSize := BYTE(IIF(oCCSevenButton:Checked, 7, 8))
        oDevice:StopBits := IIF(oCCZeroButton:Checked, 0, 2)

        IF !oDevice:SetProtocol()
            cErr := oDevice:ErrorDesc
            BREAK
        ENDIF
        // Start receiving comm events in the MLE
        oDevice:EnableEvents(EV_RXCHAR)

        // Disable Begin and Exit buttons and enable End button
        oCCBeginButton:Enabled := FALSE
        oCCExitButton:Enabled := FALSE
        oCCEndButton:Enabled := TRUE

    RECOVER
        //  Display error message
        MessageBox(0, PSZ(cErr), PSZ("Error"), MB_OK)
    END SEQUENCE

CLASS SerialMLE INHERIT MultiLineEdit
    PROTECT oComm AS Serial    // the serial object used by this MLE
    EXPORT CancelRequested AS LOGIC

DECLARE ACCESS Device

Ginny



"Martin"  wrote in message news:Lsqit.23306$sr.21245@fx09.fr7...

This line causes the error
oComm:StopBits := nStop

nStop is a byte with a value of 1

Looks like one stop bit is 0!

Aghhhhhhhhhh!!!!!!!!!!!! 

[toc] | [prev] | [next] | [standalone]


#5212

FromMartin <spam@spam.spam>
Date2013-05-10 14:16 +0100
Message-ID<Aq6jt.24145$jP.5940@fx12.fr7>
In reply to#5210
Thanks Ginny - I managed to fix that. Just awaiting a new barcode gun 
and cradle.

Currently examining 13 year old code for the processing engine

On 09/05/2013 12:13, Ginny Caughey wrote:
> Stopbits are a bit strange. Here's code from my serial tester that works:
>
> oDevice:StopBits := IIF(oCCZeroButton:Checked, 0, 2)
>
> Let me know if you need my tester code. It uses ClassMate but I'm
> including the BeginButton code here so you can see how it works:
>
> METHOD BeginButton() CLASS CommWindow
>     LOCAL cErr AS STRING
>     LOCAL dwBaud, dwParity AS DWORD
>     LOCAL cPort AS STRING
>     LOCAL oDevice AS Serial
>
>     oDevice := oDCCommEdit:Device
>
>     // Set the comm MLE to empty again
>     oDCCommEdit:TextValue := ""
>     oDCCommEdit:SetFocus()
>
>     BEGIN SEQUENCE
>         // Set comm port with values from the window's controls
>         cPort := oDCPortListBox:CurrentItem
>         IF !oDevice:Open(cPort)
>             cErr := "Cannot open port "+oDCPortListBox:CurrentItem +
> CRLF+ ;
>                 "Error code "+oDevice:ErrorCode+": "+oDevice:ErrorDesc
>             BREAK
>         ENDIF
>
>         // Set timeout values for read
>         //oDCCommEdit:Device:ReadIntervalTimeout := MAXDWORD
>         oDevice:ReadIntervalTimeout := 0    // Disable read interval
> timeouts
>         oDevice:ReadTimeoutMultiplier := 500
>         oDevice:ReadTimeoutConstant := 1000
>         oDevice:WriteTimeoutMultiplier := 0
>         oDevice:WriteTimeoutConstant := 1000
>         IF !oDevice:SetTimeOut()
>             cErr := "Can't set timeout values for scale port"
>             BREAK
>         ENDIF
>
>         dwBaud := Val(oDCBaudListBox:CurrentItem)
>         oDevice:Baud := dwBaud
>         dwParity := oDCParityListBox:CurrentItemValue
>         oDevice:Parity := dwParity
>         oDevice:ByteSize := BYTE(IIF(oCCSevenButton:Checked, 7, 8))
>         oDevice:StopBits := IIF(oCCZeroButton:Checked, 0, 2)
>
>         IF !oDevice:SetProtocol()
>             cErr := oDevice:ErrorDesc
>             BREAK
>         ENDIF
>         // Start receiving comm events in the MLE
>         oDevice:EnableEvents(EV_RXCHAR)
>
>         // Disable Begin and Exit buttons and enable End button
>         oCCBeginButton:Enabled := FALSE
>         oCCExitButton:Enabled := FALSE
>         oCCEndButton:Enabled := TRUE
>
>     RECOVER
>         //  Display error message
>         MessageBox(0, PSZ(cErr), PSZ("Error"), MB_OK)
>     END SEQUENCE
>
> CLASS SerialMLE INHERIT MultiLineEdit
>     PROTECT oComm AS Serial    // the serial object used by this MLE
>     EXPORT CancelRequested AS LOGIC
>
> DECLARE ACCESS Device
>
> Ginny
>
>
>
> "Martin"  wrote in message news:Lsqit.23306$sr.21245@fx09.fr7...
>
> This line causes the error
> oComm:StopBits := nStop
>
> nStop is a byte with a value of 1
>
> Looks like one stop bit is 0!
>
> Aghhhhhhhhhh!!!!!!!!!!!!

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web