Home AMX User Forum NetLinx Studio

Sending commands to module?

Guess who's back? The netlinx idiot with another stupid question!

I am making a module, and I'd like to be able to send "commands" to the module from the mainline. What's the best way to go about this? Would I make a virtual device, put it in the signature, then just use a data event on that?

Thanks!

Dan

Comments

  • DHawthorneDHawthorne Posts: 4,584
    Yes, create a virtual device to act as an interface, then pass it to the module as a parameter. Inside the module, use the COMMAND handler on the DATA_EVENT for the virtual to parse your commands, and use SEND_COMMAND from the main program to deploy them. For feedback, use SEND_STRING to the virtual in the module, and parse it with the STRING handler in your main program on the DATA_EVENT for the virtual. The COMMAND and STRING handlers really work exactly the same; by convention, COMMAND is used to talk to a module, and STRING for feedback. If you wanted to, you could reverse them, but it would confuse the heck out of anyone trying to figure the code out later (including you :) ). Just make good and sure you don't use the same handler for BOTH directions of communications ... they are bi-directional and you would wind up in some kind of loop at worst, and double processing everything at best.
Sign In or Register to comment.