countless thanks to Nime5ter, James and Kalle for their help ...
PY code is now (kind of) fully functional. it will raise gating event to identify which mic is sending voice stream. this is used to identify the location of the speaker and act accordingly .... as well it can be used to send commands to XAP family products (can be modified to work with AP family easily) ... for the command that sends 0/1/2 for off/on/toggle the script will generate an event confirming the execution of the command and reporting back the new state in case of toggle. for all other commands they will be executed but feedback event is not working or will raise with wrong feedback. this is due to the varying structure and number of parameters to cover all XAP commands ...
attached is sample group that uses the script ...
feedback is always appreciated ...
to setup the system, follow these steps:
Step 1: Jumper the IO port 1 on the back of XAP as following (modify as you see fits, I use this setup because I have 4 mics)
pin 17 ----> pin 1
pin 18 ----> pin 3
pin 19 ----> pin 5
pin 20 ----> pin 7
( i found a 25 D male connector in my computer junk... solders the pins as above)
Step 2: Set up the actions in GPIO builder in G ware
for pin 1, in active low : execute string 0
for pin 3, in active low : execute string 1 ...etc.
Step 3: build the strings in g-ware command strings
for string 0: \nXAP800.Gate&&0&&0\n
for string 1: \nXAP800.Gate&&0&&1\n .... etc. the first payload is the device ID (for future use) and the second payload is the gate ID
if the script loads and establish communication correctly, you should start having Gate events generated whenever a new gate triggered (if the same gate triggered multiple times, only one event will be generated - this is by design, to avoid bombarding VC with events)
Step 4 Setting up gating control
from inputs screen click on each mic "gate" button and set it up as part of group A (or any group) (right part of the image below)
from gating control (the icon with 3 mics) set that group to have
Max One mic (Left part of the image below)
this will make sure that VC will listen to only one mic if many people talk at the same time in different rooms
first obstacle; feeding the mic gate status back to VC through com port ...
I managed to feedback by installing jumpers in the back ports ... I Can see the data coming through com port ... but I can't use it in VC
1. installing http://www.eterlogic.com/Products.VSPE.html to give access to the same com port to many programs .. and it gives com port monitor
2. send the info back to VC
- through com port to UDP tunnel ...
ideally would be a python script to avoid installing new software and get the possibility to filter the data ... till now this solution causes VC to crush #Gentner Serial Communication Script
#version 0.6 will excute all commands but raise event only with queries
#and commands that has 0/1/2 as parameter. Support string feedback if starts
#XAP800.Gate, requires hardware jumpers installed on IO 1
#Based on read/write to serial port by James&Kalle
#you must have enabled the python-plugin in VoxCommando
#start this python script with VoxCommando
#Many thanks for the support from Nime5ter, James and kalle
#without their help this wouldn't be possible
import clr
clr.AddReference('System')
from System import *
from System.Collections.Generic import *
import socket
def sendUDP (MESSAGE, UDP_IP, UDP_PORT):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
lastData="xyz"
lastCommand="xyz"
def Ondata (sender, event):
global lastData
global lastCommand
sData = sender.ReadLine ()
#print sData
if (sData[:11] == "XAP800.Gate")and(sData != lastData):
lastData = sData
sendUDP("vc.triggerEvent&&"+lastData, "127.0.0.1", 33000)
if (len (sData) > 5) and (sData[:3] == "OK>" ):## if length is 5, it is \lOK>\s from previous command
sData = sData[4:-1] ## trim OK> and \l at the end
if (len (sData) == len (lastCommand) ) and (sData[:-1]==lastCommand[:-1]): ## this probably a command Response
sendUDP("VC.TriggerEvent&&XAP800.Response&&"+lastCommand+"&&"+sData[-1:], "127.0.0.1", 33000)
elif (sData[:len (lastCommand)] == lastCommand ): ## this is probably a query command Response
sendUDP("VC.TriggerEvent&&XAP800.Response&&"+lastCommand+"&&"+sData[1+len (lastCommand):], "127.0.0.1", 33000)
if (sData[:5] == "ERROR"):
sendUDP("VC.TriggerEvent&&XAP800.Error&&"+lastCommand+"&&"+sData[8:], "127.0.0.1", 33000)
def XAPcommand(str):
global lastCommand
serialPort.WriteLine(str)
lastCommand = str
serialPort = IO.Ports.SerialPort("COM1") #set here the serial port connected to XAP800
serialPort.BaudRate = 38400 # default Baudrate for XAP800 38400
serialPort.DataBits = 8
#serialPort.DtrEnable = True
serialPort.RtsEnable = True
serialPort.DataReceived += Ondata
eventPayload=List[str](["COM1",str(serialPort.BaudRate),str(serialPort.DataBits)])
try:
serialPort.Open()
except:
vc.triggerEvent("XAP800.Port.Failed",eventPayload)
else:
vc.triggerEvent("XAP800.Port.Opened",eventPayload)