programmatically emulate receiving from serial device?
travis
Junior Member
I've been using the Emulate a Device panel a lot lately and I'd like to just put some code into my mainline to automate my testing a little.
I naively tried:
but nothing showed up at my data event.
Is this possible?
I naively tried:
DEFINE_PROGRAM
WAIT 30 { send_string 5001:1:0 , "'R123',13" }
but nothing showed up at my data event.
Is this possible?
Comments
-
Pretty sure that will only send data to the device you are controlling. Since you are emulating a device, I imagine you wanted that string to appear to come into the port, not go out.
I don't know of a way to simulate this with code (could very well be possible). But if you are using a buffer to parse the data, you could just assign the string to the end of the buffer. But you would have to parse in mainline as no Data_Event would be generated.
If not, you could loop the TX pin to the RX pin of the com port and use the code you have. AMX will send the string out the TX port which will immediately come back into the RX port.
Kevin D. -
Right. D'oh.shr00m-dew wrote: »I imagine you wanted that string to appear to come into the port, not go out.
I hope it's possible. I want to test my actual Data_Event code. If I could do this, I could write a bunch of elaborate tests, and then when I plugged in the actual sensors, they would Just Work.I don't know of a way to simulate this with code (could very well be possible). But if you are using a buffer to parse the data, you could just assign the string to the end of the buffer. But you would have to parse in mainline as no Data_Event would be generated.
I'd try this, but I don't have any actual hardware handy.If not, you could loop the TX pin to the RX pin of the com port and use the code you have. AMX will send the string out the TX port which will immediately come back into the RX port.
Kevin D.
I guess we could also write some serial port emulator program outside of netlinx.
thanks -
You can connect two of your master's serial ports together and program the second serial port to act like the device you want to control.
-
Another way may be to use a virtual device for testing. Instead of a physical port (i.e. 5001:1:0) create and use a virtual device (i.e. 33001:1:0). If you now do a SEND_STRING to the virtual device, you will get the string from the virtual device immediately.
But keep in mind that this may not be the "real world"
-
Make a cross cable (2 to 3 : 3 to 2) from one rs232 port to an other.
send_string 5001:1:0, 'test'; //port 1 loop to port 2 data_event[5001:2;0] { string: send_string 0, "data.text"; }Or you could just use a virtual. -
Marc Scheibein wrote: »Another way may be to use a virtual device for testing. Instead of a physical port (i.e. 5001:1:0) create and use a virtual device (i.e. 33001:1:0). If you now do a SEND_STRING to the virtual device, you will get the string from the virtual device immediately.
But keep in mind that this may not be the "real world"
This works and I only had to change a few things that can easily be changed back for the real sensors.DEFINE_DEVICE dvVirtual = 33001:1:0 dvVirtual2 = 33002:1:0 dvVirtual3 = 33003:1:0 DEFINE_VARIABLE DEV Virtuals[3] = {dvVirtual, dvVirtual2, dvVirtual3} DEFINE_EVENT DATA_EVENT [ Virtuals ] { STRING:{ x = data.device.number - 33000 // do stuff depending on which device caused the event } } Define Program Wait 20 r_num = RANDOM_NUMBER(25); send_string dvVirtual, "ITOA(r_num),13" Wait 20 r_num = RANDOM_NUMBER(25); send_string dvVirtual1, "ITOA(r_num),13" Wait 20 r_num = RANDOM_NUMBER(25); send_string dvVirtual2, "ITOA(r_num),13"Right now I'm trying to figure out the right way to to nest the waits so they will happen in order, 2 seconds apart...
Edit: using a timeline now. Works well. Awkward to set up though.
Thanks, guys!
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums