sending commands problem
udi
Posts: 107
I have problem with sending commands to a device. Sometimes when I am doing a send command to the device the command doesn’t sent properly. Because it gets some commands together and not one command each time.
I am trying to do a function that gets called every time I am sending a command to the device and gets put into a queue before sending it so that proper wait time is place in between commands. But I don’t know how to do that.
Anyone knows how to do that? Or maybe have an easier way?
I am trying to do a function that gets called every time I am sending a command to the device and gets put into a queue before sending it so that proper wait time is place in between commands. But I don’t know how to do that.
Anyone knows how to do that? Or maybe have an easier way?
0
Comments
Button Event: Q Function: Process Q to send strings: TIME_LINE (could be DEFINE_PROGRAM): Note sTVmod.nCTS is reset upon RX from devices and the wait gets canceled. You'll have to adpt this to your code and change the necassary vars but once you get this you'll be golden. Also note that "IP_CLIENT_CONNECTED" doesn't necassarily mean it's an IP device. In this case it just means the dev is ONLINE. In this module the dev could be IP, 232 or IR.
Hi vininig,
I didn’t I understood your variables.
What data types sTVmod including and what each variable means. Can you explain more about the variables you have in the code?
I have an iLight device and the commands I sent is: SEND_STRING dvILIGHT, "'@SC001:A001:L100:F004',13" ( for example). So I need to put the string : @SC001:A001:L100:F004' into the queuing.
How I do it? How can I change your code? which vars I need to change???
Regrds,
udi
I have to run so I can't elaborate any more right now. Maybe later when I get back online.
Hi vining
I begin to understand your code.
But I still need a little help.
1. there are some parameters I did not understand and what their value are :
nTL_QRT, TV_TX_CTS, TV_TX_BUSY , TV_CTS_TIMEOUT , nTicToc
sTVmod.nCTS,
sTVmod.nConState
2. the parameter sTVmod.nCmdSent isn't declared in the code .
3. where do you use: CANCEL_WAIT 'TL_KILLED_QUERY' ;
4. Do I need to initialize sTVmod.nQTail and sTVmod.nQHead to 1
5. In my code I need to send 2 types of coomands.
SEND_STRING dvILIGHT, "'@SC004:A001:L100:F004',13"
SEND_STRING dvILIGHT, "'@RC04:A01',13"
So I only need the cCmd but what length should be variable right
How do I set the variable to be sometimes the first command length and sometimes the second command length?
I hope you could help me Thanks
sTVmod.nCTS & sTVmod.nConstate are members of STRUCTURE _sTVmod. .nCTS is sent to TV_TX_BUSY when I send a string to the device. It has a time out in case a response is not recieved where it is set to TV_TX_CTS and the timeout wait is canceled and .nCTS is set to TV_TX_CTS when a response is received form the device. sTVmod.nConState is set to IP_CLIENT_CONNECTED in the devs online event handler. To disco in the offline and either disco or disabled in the onerror. If it's IR or serial RS232 device it's not that important to track and manage the connection state.
Here's the start up code that initializes my head and tail:
My online event:
I used a multi part queue so I could logically seperate my commands from my parameters to simplify later comparing to responses but you could easily just create an array to hold the entire string and make it long enough to hold your longest possible string.
Instead of using an array and the head & tail pointers you could just as easily create a char array 512 bytes long (shorter or longer) and just concanenate your commands to it to create one long string type queue. When it's time to send a string just grab up to and including "13". (Uses 13 as the delimeter) The just do something like "send_string dev, remove_string(LongStringQueue,"13",1) ; which will pull the first command in the string.