Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading and Writing to a Serial Port
Message
De
07/02/1999 08:19:53
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Reading and Writing to a Serial Port
Divers
Thread ID:
00184838
Message ID:
00184838
Vues:
54
I am looking for a reasonable fast way to read and write to a serial port from within VFP. The following is a quick basic example program. How can I do this in VFP?

CONST SetX = 16, SetY = 32, SetZ = 64 ' Define constants
CONST XCW = 0, XCCW = 16, YCW = 0, YCCW = 32, ZCW = 0, ZCCW = 64

CLS : OPEN "COM1:9600,N,8,1" FOR RANDOM AS #1 ' Init. Comm. Port
DO UNTIL EOF(1) ' Do not start communications
I = ASC(INPUT$(1, #1)) ' until the serial port
LOOP ' input buffer is empty.

PRINT #1, CHR$(SetZ + 1); ' X and Y = full step, Z = half step.
PRINT #1, CHR$(2); ' No limit sense for any steppers.
PRINT #1, CHR$(SetY + 3); ' Y = 2 phase excitation.
PRINT #1, CHR$(4); ' Set a step rate
PRINT #1, CHR$(160); ' clock of 160.
PRINT #1, CHR$(SetX + 5); ' Set the speed divisor for
PRINT #1, CHR$(5); ' stepper X to 5.
PRINT #1, CHR$(SetY + 5); ' Set the speed divisor for
PRINT #1, CHR$(10); ' stepper Y to 10.
PRINT #1, CHR$(SetZ + 5); ' Set the speed divisor for
PRINT #1, CHR$(15); ' stepper Z to 15.

Thanks
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform