X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=libcbfwr%2Fcomms.php;h=610959e04d0482fe69d40541f9db5dd458a34038;hb=4b79d489f91d4bca8b1451daa3415b73545b08c2;hp=b1195c959def395cc0aaf7e0e7336d3482ce113e;hpb=a52a53bbe7ad884562d7fb39c87442a38e331dd2;p=CBFWR.git diff --git a/libcbfwr/comms.php b/libcbfwr/comms.php index b1195c9..610959e 100644 --- a/libcbfwr/comms.php +++ b/libcbfwr/comms.php @@ -15,33 +15,43 @@ class Comms { $this->msgres = msg_get_queue($MESSAGE_KEY, 0666); } - function getConfig() + function getConfig($type=0) { global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY; sem_acquire($this->semres); $shm_space = shm_attach($STORE_KEY, 16*1024*1024); - $config = shm_get_var($shm_space, 0); + $config = shm_get_var($shm_space, $type); sem_release($this->semres); return $config; } - function putConfig($config) + + // type = 0 for the main config + // type = 1 for the boot hardware config + function putConfig($config, $type=0) { global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY; sem_acquire($this->semres); $shm_space = shm_attach($STORE_KEY, 16*1024*1024); - shm_put_var($shm_space, 0, $config); + shm_put_var($shm_space, $type, $config); sem_release($this->semres); } function waitForMessage() { + global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY; + $queue = msg_get_queue($MESSAGE_KEY); + msg_receive($queue, 0, $msgtype, 1024, $msg); + return $msg; } - function sendMessage() + function sendMessage($msg) { + global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY; + $queue = msg_get_queue($MESSAGE_KEY); + msg_send($queue, 1, $msg); }