Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Receiving Data on Com Port
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00099320
Message ID:
00110485
Vues:
26
I'm not sure what is going on. We probably have cable problems because the Hyperterminal is not consistent either. I'll let you know if there is anything other than that to pass along. Yes, it is hot....

Eric K.

>Hi Chaweng,
>How are things in Thailand. I visited there once trying to train some staff in Foxpro. (I don't think I was very good :-)) And it was really hot!!!
>Anyway, back to MSCOMM
>You should see the same characters coming in as Hyperterminal. In fact I used Hyperterminal to check that my app was working.
>You must have something wrong somewhere. You might need some handshaking protocol set on to something other than what I used. Set it to match the sender protocol. This shouldn't upset the other settings.
>If all else fails try CommTools, 3rd party library.
>Dave
>
>
>
>>It's me again,
>>
>>I'm recieving data right enough, but it is jiberish. You know, little squares and things that look like funny Qs and such. The Hyper terminal in Win95 takes the same data and prints real letters. Does fox need to translate this data to regular text? I must admit I don't know how to do that. Some little known function maybe?
>>
>>Eric K.
>>
>>
>>>>
>>>> I've been reading the help on MSCOMM32 and I'm not real clear on how to use the events and methods available. The examples are in VB and I believe use VB defined variables. Anyway can you help me with a short snippet. I need to just open com1 which I think is ok, but I need to continually loop for a recieve event and print the buffer to screen or to file. Can I set a timer to check OnComm? I dunno. Can you tell me the proper way to do this?
>>>>
>>>>Eric Kleeman
>>>
>>>Well here's how I do it....
>>>
>>>Properties...
>>>DTRENable = .T.
>>>Enabled= .F.
>>>Handshaking = 2
>>>InputMode = 0
>>>RTSENable= .T.
>>>RTTHreshold= 1
>>>SThreshold= 0
>>>Settings= {whatever you need - im using} 9600, n, 8, 1
>>>
>>>Init Event...
>>>THIS.CommPort= 2
>>>THIS.interval= 55
>>>
>>>OnComm Event...
>>>* I'm doing my on double buffering, hope you get the idea...
>>>WITH THISFORM
>>> .recbuffSMDR= .recbuffSMDR + THIS.input
>>> * look for you terminating chr...
>>> IF ! .processing AND AT(CHR(10), .recbuffSMDR)>0
>>> .processing= .T.
>>> THISFORM.ledSMDR.backcolor= RGB(255, 0, 0)
>>>
>>> * double buffer...
>>> .buff= .recbuffSMDR
>>> .recbuffSMDR= ""
>>> .procBuffSMDR
>>> .processing= .F.
>>>
>>> THISFORM.ledSMDR.backcolor= RGB(128, 0, 0)
>>> ENDIF
>>>ENDWITH
>>>
>>>form.procBuffSMDR...
>>>#DEFINE k_EOL CHR(10)
>>>WITH THISFORM
>>> LOCAL nl, cs, cStr
>>> nl= RAT(k_EOL, .buff)
>>> cs= CHRTRAN(LEFT(.buff, m.nl), CHR(13), "")
>>>
>>> IF m.nl < LEN(.buff)
>>> * send the leftovers back to the beginning of the original buffer!
>>> .recBuffSMDR= SUBSTR(.buff, m.nl+1) + .recBuffSMDR
>>> ENDIF
>>>
>>> * parse cs
>>> FOR m.ii = OCCURS(k_EOL, m.cs) TO 1 STEP -1
>>> IF m.ii = 1
>>> nStart= 1
>>> ELSE
>>> nStart= AT(k_EOL, m.cS, m.ii-1)+1 && just after previous EOL
>>> ENDIF
>>> nEnd= AT(k_EOL, m.cS, m.ii)
>>> cStr= SUBSTR(m.cs, m.nStart, m.nEnd-m.nStart)
>>>
>>> * cStr is now your single record data string
>>>
>>> * call a function here to do whatever with it
>>>
>>> ENDFOR
>>>ENDWITH
>>>
>>>
>>>
>>>
>>>
>>>The Oncomm event doesn't need a timer, it just fires off whenever it feels like it :-) !!!
>>>
>>>HTH
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform