Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to put a 1/0 on that pin?
Message
From
08/11/2003 13:59:00
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
How to put a 1/0 on that pin?
Miscellaneous
Thread ID:
00847960
Message ID:
00847960
Views:
68
Hello everybody.

In my free time <bg>, I am working on some different researches. One of the projects I am currently working on is controlling a comm-port, to eventually be able to use for different applications. 'Smart houses', 'computer controlled routing machines', etc come to mind here. My guess is that those programs are usually done in c++ or so, but hey - I am a committed fox fan!

So, I have been starting (or I rather should say trying) to find out how I could do that (manipulating and eventually also reading) a comm.-port. So I hooked up a cable to my comm 1, attached a volt meter to the cable (checking all the different pins against ground) , and started my test program.

First I initialize the port :
oComm = CREATEOBJ('MSCOMMLib.MSComm')
oComm.CommPort = 1
oComm.Settings = "9600,N,8,1"
oComm.InputLen = 0
oComm.PortOpen = .T.
Then, I had 2 different tests.
The 1st one sends for some time a '1' to the port and then a ‘chr(0)’ - I know, a '1' and a chr(0) are probably not the correct way to switch a pin on and off, but I am just testing to see what happens.
FOR I=1 TO 5
	?1
	FOR x=1 TO 5000
		oComm.OUTPUT = "1"
	ENDFOR
	?0
	FOR x=1 TO 5000
		oComm.OUTPUT = chr(0)
	ENDFOR
ENDFOR
Well, something happened that’s for sure. My volt meter's display changed quite a bit. But I don't have such a fancy one, so I couldn't really distinguish how it was responding and to what. Plus, I don't know if I send a signal to the port, if it stays. I don't think it does, it most likely just gets send and then disappears.
So, test 2 just sends a signal 1 single time
oComm.OUTPUT = "1"
Well, that didn't do nada, zip, zilch, nix, zero. Probably is too fast for the volt meter.

At the end of course I close the port
oComm.PortOpen = .F.
RELEASE oComm
So here are some of my questions:

  • is what I want to do possible at all with 'MSCOMMLib.MSComm'?
  • how do I specify a specific pin?
  • what chr() do I have to send to 'switch on' and to 'switch off'?
  • how do I keep that signal on the pin, or should that be the responsibility of the electronics attached to the computer?
  • and finally, how do I 'read' a state of a pin?

    Like I mentioned at the beginning, I am playing around with this at the moment. But it intrigues me, and I think it would be big fun to write a few simple apps to control a few things - and if it's just a night light when you're on a vacation (if I ever get one ).

    So, if anyone has ever done this, in vfox or any other language - please help

    I appreciate any suggestions from you all and thank you in advance.
  • Next
    Reply
    Map
    View

    Click here to load this message in the networking platform