Hello,
I'm trying something but doesn't work :s Here is my idea :
In my cfg file i added the following lines : if (is_gflag("10")) xlog("L_INFO", "gflag is 10");
I'm using MI Commands to set gflag to 10 so : $ kamctl fifo set_gflag 10
After that if i look on my log file there is no "gflag is 10" !!
Am i using the module and MI commands in the right way ?
Thanks
Hello,
On 05.08.2009 10:59 Uhr, karhu wrote:
Hello,
I'm trying something but doesn't work :s Here is my idea :
In my cfg file i added the following lines : if (is_gflag("10")) xlog("L_INFO", "gflag is 10");
I'm using MI Commands to set gflag to 10 so : $ kamctl fifo set_gflag 10
After that if i look on my log file there is no "gflag is 10" !!
Am i using the module and MI commands in the right way ?
IIRC, the mi command takes a bitmask as value while the config function takes the index in bitmask. So, if you want to test flag 2:
if(is_gflag("2"))
kamctl fifo set_gflag 4
4 = 2^2
For flag ten you have to set it via mi to 2^10 which is 1024.
Try and see if works.
Cheers, Daniel
Daniel-Constantin Mierla wrote:
IIRC, the mi command takes a bitmask as value while the config function takes the index in bitmask. So, if you want to test flag 2:
if(is_gflag("2"))
kamctl fifo set_gflag 4
4 = 2^2
For flag ten you have to set it via mi to 2^10 which is 1024.
Try and see if works.
This seems inconsistent and needlessly complicated and does not follow from the documentation at all. I would recommend changing the set_gflag MI function to take the bit offset as an argument rather than the bitmask if is_gflag() checks the offset.
Alex Balashov wrote:
Daniel-Constantin Mierla wrote:
IIRC, the mi command takes a bitmask as value while the config function takes the index in bitmask. So, if you want to test flag 2:
if(is_gflag("2"))
kamctl fifo set_gflag 4
4 = 2^2
For flag ten you have to set it via mi to 2^10 which is 1024.
Try and see if works.
This seems inconsistent and needlessly complicated and does not follow from the documentation at all. I would recommend changing the set_gflag MI function to take the bit offset as an argument rather than the bitmask if is_gflag() checks the offset.
Well, OK, I take that back -- it does follow from the documentation, if the parenthetical statements are payed careful attention. I still think it should be changed on the MI side to be more consistent and easier to work with.
The other problem with the current situation is that in order to set a particular bit to 1 without wiping out any other flags that may have been set in the past, it is necessary to first get the current value from get_gflags and manually do the math. That's needlessly complex for users who aren't programmers; not everybody has the powers of 2 and the common products of powers of 2 memorised.
-- Alex
On 05.08.2009 12:03 Uhr, Alex Balashov wrote:
Alex Balashov wrote:
Daniel-Constantin Mierla wrote:
IIRC, the mi command takes a bitmask as value while the config function takes the index in bitmask. So, if you want to test flag 2:
if(is_gflag("2"))
kamctl fifo set_gflag 4
4 = 2^2
For flag ten you have to set it via mi to 2^10 which is 1024.
Try and see if works.
This seems inconsistent and needlessly complicated and does not follow from the documentation at all. I would recommend changing the set_gflag MI function to take the bit offset as an argument rather than the bitmask if is_gflag() checks the offset.
Well, OK, I take that back -- it does follow from the documentation, if the parenthetical statements are payed careful attention. I still think it should be changed on the MI side to be more consistent and easier to work with.
The other problem with the current situation is that in order to set a particular bit to 1 without wiping out any other flags that may have been set in the past, it is necessary to first get the current value from get_gflags and manually do the math. That's needlessly complex for users who aren't programmers; not everybody has the powers of 2 and the common products of powers of 2 memorised.
indeed, awkward and this is prone to errors and races if script sets also the flag. Personally, I have been using $shv(x) to control config behavior and there I dealt with values not flags.
Cheers, Daniel
I've been using $shv(x) as well !!
In the cfg file :
modparam("pv", "shvset", "x=i:1")
if ($shv(x) == 100) { xlog("L_INFO", "shv_set_to_100"); }
In my console : kamctl fifo shv_set x int 100
But still no shv_set_to_100 in my message log file :(
i tried with :
if ($shv(x) == 1) { xlog("L_INFO", "shv_set_to_1"); }
and shv_set_to_1 is in the log file..
Weird
It looks like when i am doing kamctl "fifo shv_set x int 100" nothing is display in the log file.. but when i am making a call or hang up just after having using the MI commands, "shv_set_to_100" is display on the log.. I thought i could have played with MI commands and shared variable to have real time interaction with the cfg file..
On 05.08.2009 15:18 Uhr, karhu wrote:
It looks like when i am doing kamctl "fifo shv_set x int 100" nothing is display in the log file.. but when i am making a call or hang up just after having using the MI commands, "shv_set_to_100" is display on the log.. I thought i could have played with MI commands and shared variable to have real time interaction with the cfg file..
not sure I understood what you look for and what works/does not work. Is the set of shv variable via mi working? I have been using it and no problem so far.
Cheers, Daniel
What i would like to do is when i am using the MI command "kamctl fifo shv_set x int 100" it set the variable shv(x) to 100 and execute straight after the code on the following bloc :
if ($shv(x) == 100){ xlog("L_INFO", "shv_set_to_100") }
In a near futur i would like to send a BYE and RE-INVITE to a user when i'm setting shv(x) to 100 via MI command..
On 06.08.2009 9:30 Uhr, karhu wrote:
What i would like to do is when i am using the MI command "kamctl fifo shv_set x int 100" it set the variable shv(x) to 100 and execute straight after the code on the following bloc :
if ($shv(x) == 100){ xlog("L_INFO", "shv_set_to_100") }
the xlog line will be executed upon first sip message processed. Not at the time when you set the variable. Configuration file interpretation is triggered by incoming sip messages, not by MI commands.
You can execute a certain route by using the rtimer module. Next version, will have the feature of executing a config file route upon xmlrpc request (see sip-router.org GIT repository and the xmlrpc module in modules_s directory).
Cheers, Daniel
In a near futur i would like to send a BYE and RE-INVITE to a user when i'm setting shv(x) to 100 via MI command..
On 05.08.2009 12:00 Uhr, Alex Balashov wrote:
Daniel-Constantin Mierla wrote:
IIRC, the mi command takes a bitmask as value while the config function takes the index in bitmask. So, if you want to test flag 2:
if(is_gflag("2"))
kamctl fifo set_gflag 4
4 = 2^2
For flag ten you have to set it via mi to 2^10 which is 1024.
Try and see if works.
This seems inconsistent and needlessly complicated and does not follow from the documentation at all. I would recommend changing the set_gflag MI function to take the bit offset as an argument rather than the bitmask if is_gflag() checks the offset.
I kind of agree. Maybe the best is to add new mi commands:
set_gflag_ny_bitmask - which actually replicates the current command set_gflag_by_index - which sets a bit at a position
keep the old for compatibility, or remove if people agree.
Cheers, Daniel
IIRC, the mi command takes a bitmask as value while the config function takes the index in bitmask. So, if you want to test flag 2:
if(is_gflag("2"))
kamctl fifo set_gflag 4
4 = 2^2
For flag ten you have to set it via mi to 2^10 which is 1024.
Try and see if works.
Cheers, Daniel
Thanks for informations but doesn't work.. I've been loading cfgutils module and when i am using MI command everything seems to be fine..
kamctl fifo set_gflag 1024 database engine 'MYSQL' loaded Control engine 'FIFO' loaded entering fifo_cmd set_gflag 1024 FIFO command was: :set_gflag:openser_receiver_4180 1024
using is_gflag("10") in cfg file.
Are there others issues to command cfg file ?
In my user point of view (set_gflag_by_bitmask and set_gflag_by_index) seem to be a good idea. It will be more understandable than power of 2 ^^