How Can I Use the ASCII Object in Lookout to Send Data to an external device?Primary Software: LookoutPrimary Software Version: 5.0 Primary Software Fixed Version: N/A Secondary Software: N/A
Problem: I would like to use Lookout to communicate to an external device through a serial port or ethernet. I know I need to use the ASCII object, but I don't understand how it works. Solution: If you want to send and receive ASCII data from the serial port, you have to use the ASCII object. When sharing ASCII data over ethernet, you need to use the IPASCII object. If you want more information on the ASCII or IPASCII object, consult the reference manual or create a simple example using the tutorial below. Follow these instructions to write a simple example using the ASCII object. By stepping through the process, you should get a good understanding of how the ASCII object works and how to program with it. (Note: For example purposes, we will use the ASCII object for explanation. The only difference in the use of the ASCII object and the IPASCII object is the configuration of the parameters. After you have specified an IP address and a port for the external device, the IPASCII object in Lookout functions the same as the ASCII object.) Before you open Lookout, connect a serial cable to one of your COM ports. In the example, COM1 is used. If you put your serial cable on a different COM port, then make sure to make the appropriate changes in your program. Take the other end of the cable and jump pins 2 and 3. To jump pins 2 and 3, use a paper clip to connect the two pins. A serial cable used with this configuration is called a loopback cable. The following steps will work assuming that you do not have any other existing problems with your serial port. If you are not sure if you are having problems with your serial port, try to communicate with the port in Hyperterminal. Only one program at a time can access the serial port. So, if you check the port with Hyperterminal, make sure that Lookout is closed. Once you go into Lookout, make sure that no other program is trying to access the serial port. We are going to send a number and a string to the serial port in this example. All of the objects are created assuming that the categorize box is not checked and the objects are then listed in alphabetical order.
** Why did we use RQV1 for the pot and RQV2.txt for the string? When Lookout sends the data across the serial port, it sends whatever is in its RQV* members. RQV* is for numeric members. RQV*.txt is for string or text members and RQV*.logical is for logical members. If you set RQV1 = Pot1 and RQV1.txt = TextEntry1, you would have problems. Lookout sends its RQV* members in sequential order. If it had two members that were equal (RQV1 and RQV1.txt) it would not know which one to send first, and you would get unpredictable results.
If you have problems getting your program to work, compare your lks file to the lks file attached below. You may need to confirm that your serial port is working properly. Once you get this program working, try changing your RequestFormat and ResponseFormat strings. Try a "%d %s" (a space between %d and %s). See what happens if you change the RequestFormat string but not the ResponseFormat string (and vice versa). If you have problems communicating with a serial device in the future, return to the loopback cable test to make sure you are sending the right data to the device. Related Links: Attachments:
Report Date: 11/02/1999 Last Updated: 01/05/2005 Document ID: 1R18NERM |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
