Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Serial Port Communication is not working as intended
Message
De
12/04/2007 10:36:55
 
 
À
11/04/2007 15:56:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 6
OS:
Windows NT
Divers
Thread ID:
01214675
Message ID:
01214971
Vues:
10
Thank you for all your help, and it was insightfull.
I've made some changes, but I'm still getting the same problem. I tried using a set step on to see what the problem is, and it seems the oncomm event is always some crazy number, everytime i run it. I've had it equal -1, 208, 4408, 5 and others. But it never equals 2. Maybe I'm testing it wrong, I dont know.


What I'm doing is hooking another computer up on the serial port. I run hyperterminal on the other computer and then run this program on this computer. In hyperterminal i just mash some keys and press enter while the program is running in set step on mode, and the commevents always will equal one of thsoe crazy numbers, for the entire time. It will never change to 2.

I feel so lost, and have no clue on what to do next. Someone plz help me.

Here is my code now:
SET DEFAULT TO curdir()
set step on
*** downloaderHex.TXT must exist ***
IF FILE('downloaderHex.txt')
	dHex = FOPEN('downloaderHex.txt')   && Open the file
ELSE
	WAIT WINDOW "DownloaderHex does not exist"
ENDIF
IF dHex < 0
	fclose(dHex)
	fopen("downloaderHex.txt")
	WAIT WINDOW "Error Opening DownloaderHex.txt"
ENDIF


PUBLIC ComForm
   ComForm = CREATEOBJECT('Form')
   ComForm.AddObject("Testcom","Olecontrol","MSCOMMLib.MSComm")
   ComForm.Testcom.CommPort = 2 && Use Comm2, The second Serial Port.
   ComForm.Testcom.Settings = "9600,N,8,1"  && 9.6 Kbaud, No Parity,
                                             && 8 data Bits, 1 Stop Bit
   ComForm.Testcom.PortOpen = .T.  &&opens the Serial Port
   ComForm.Testcom.RThreshold = 1  &&Sets the Serial ports buffer to recieve
   									&&when 1 character is stored
   ComForm.Testcom.InputLen = 1 &&Amount of characters it reads from the buffer

DO WHILE !FEOF(dHex)
AutoYield = .F.
IF ComForm.Testcom.CommEvent = 2  &&This is triggered if the RThreshold is reached
	oneChar = CHR(VAL(ComForm.Testcom.Input))
	charLine = charLine + oneChar
	IF vbCrLf $ charLine  &&If a Carriage return is recieved
		firstLine = FGETS(dHex)	&&Get a line of code from the txt file
	   ComForm.Testcom.Output = ">[1]" + firstLine + vbCrLf &&sends a line from the Hexfile
	   WAIT WINDOW firstLine NOWAIT
	ENDIF
ENDIF
ENDDO
fclose(dHex)
WAIT WINDOW "DONE SENDING ALL LINES FROM DOWNLOADERHEX.TXT" 
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform