General information
Category:
Windows API functions
Title:
Reading and Writing to a Serial Port
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
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only