Link to home
Start Free TrialLog in
Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScFlag for Zambia

asked on

How to implement a sleep sub in a serial port

I need to implement or add a sleep sub routine in Ms Access between the commwrite & commread so that I'm sure that all the data received from the gadget is read and received into my database. Now below is my draft sub routine see how to improve it. The gadget writes all the invoices without problems see attached screen, the only issue here is receiving that why the suggestion for a sleep sub:

Dim strData  as string
Dim strDataComplete as string

        strDataComplete = ""
        Do While True ' Loop until serial port is read
            Sleep 1000
            lngStatus = CommRead(intPortID, strData, 100000) 'For 100000 is the max data length you want read, change to suite
            Sleep 1000
            If lngStatus = 0 Then
               'Keep polling to see if serial has data
            ElseIf lngStatus <> 0 Then
                strDataComplete =  strData 'Put data pulled from serial port here 
            End If
            If lngStatus = 0 And strDataComplete <> "" Then
                Exit Do    ' Exit loop when all data is read
            End If

Open in new window

User generated image
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Avatar of Bill Prew
Bill Prew

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial