Using OSC in Arduino from Touch OSC MultiToggle - arduino

I can not find an OSC library for Arduino that supports Touch OSC's multitoggle controls. Am I doing something wrong, or is there a library that does have support for this control?
The library I'm using: https://github.com/recotana/ArdOSC
The OSC message I'm sending from Touch OSC:
/octobar/togglearray/2/2 1.
The Snippet relative to catch it on the Arduino:
server.begin(serverPort);
server.addCallback("/octobar/togglearray",&togglearray);
void togglearray(OSCMessage *_mes) {
Serial.println("Toggle Array");
}
I do have other callbacks working, and I have not pasted all of the server code here since it is working with fader and push button controls. The problem seems to be any control that supports multiple selection.

I have been trying to do almost exactly this and switched to the Z_Osc library as I could not work out how to parse the incoming messages using ArdOsc.
I do something like this:
rcvMes=server.getMessage();
mess=rcvMes->getZ_OSCAddress();
if (mess.startsWith("/1/multitoggle1/")) {
y=(mess.substring(16)).toInt();
x=(mess.substring(19)).toInt();
}

Related

Create a bluetooth connection Kivy

This is more of a basic OOP question than a Kivy one. I have an app with 4 buttons. When I press one, I want to initialize a bluetooth connection from my laptop to an arduino uno and also schedule a function that sends bluetooth info every second.
I'm using the following code:
class HomeScreen(Screen):
def OnConnect(self):
print('Start')
port = "COM7"
#connect to bluetooth
bluetooth = serial.Serial(port, 9600)
print("Connected to HC-06")
bluetooth.flushInput()
#schedule a function that sends tester present to arduino
Clock.schedule_interval(self.SendData, 1)
def SendData(self,*args):
bluetooth.write(b"Boop")
Obviously "bluetooth" is not visible outside fct "OnConnect". I want bluetooth to be visible to both OnConnect & SendData but I only want to connect to the arudino when OnConnect is called. Any help is appreciated.
I've looked at the documentation at:
https://kivy.org/doc/stable/api-kivy.clock.html
It says:
If you want to schedule a function to call with default arguments, you can use the functools.partial python module:
So I would think something like this should work:
#schedule a function that sends tester present to arduino
Clock.schedule_interval(partial(self.SendData, bluetooth), 1)
def SendData(self, bt):
bt.write(b"Boop")

Writing to Arduino's serial monitor box

I'm trying to send SMS using GPRS attached to Arduino.
I have this code:
// send an SMS!
char sendto[21], message[141];
flushSerial();
Serial.print(F("Send to #"));
readline(sendto, 20);
Serial.println(sendto);
Serial.print(F("Type out one-line message (140 char): "));
readline(message, 140);
Serial.println(message);
if (!fona.sendSMS(sendto, message)) {
Serial.println(F("Failed"));
} else {
Serial.println(F("Sent!"));
}
I tried to send, and it is working perfect, but I have to use the serial monitor box to enter the number and the message, and the library is using only this method. I want the code to run by itself without entering anything in the box.
Is there is any way so I can do that? I mean something like writing automatically to the box from the code.
Thank you in advance!
Best regards,
Take out the parts of the code that read the line from the Serial monitor and replace with lines of code that either have the data it needs hard-coded or has some other way to get that data. You really haven't shown enough of the code to help you figure out how to do that.

Serial port access in vxworks not working

I am in a need to send data thru serial port in vxworks. I am using the following code. But
it is not working.can anyone point out what went wrong?
int f;
if(f=open("/tyCo/1",O_RDWR,0)<0)
{
printf("Error opening serial port.");
return 1;
}
write(f,"hello",5);
after running this code, no data is comming thru serial port but instead it comes thru
terminal(Tornado shell). The system has two serial devices /tyCo/1 and /tyCo/0. I tried them both, but the problem persists.
Thanks in adavnce
Likhin.
Have you set the baud rate?
if (iocl(m_fd, FIOBAUDRATE, rate )) == ERROR )
{
//throw error
}
It is possible that you are using the wrong name for the device, and that Tornado Shell is set to your default device. From vxdev.com:
If a matching device name cannot be found, then the I/O function is directed
at a default device. You can set this default device to be any device in the
system, including no device at all, in which case failure to match a device
name returns an error. You can obtain the current default path by using
ioDefPathGet( ). You can set the default path by using ioDefPathSet( ).
The 3rd parameter of "open" command is, if I am not wrong, the mode. I do not really understand what it is needed for in vxworks, except for code comparability with UNIX. In short -try to give some value like 0644 or 0666. I think this will help.

pySerial writes to Arduino Uno get buffered

I have a Python script that writes short messages to the serial port on my Arduino Uno board using pySerial. There is a loop and depending on some conditions, multiple writes can happen within a loop, something like this:
while True:
#Conditions block 1
if <CONDITION1>:
serial.writelines("INIT")
elif <CONDITION2>:
serial.writelines("NEW")
...
#Conditions block 2
if <CONDITION1>:
# Fetch something from the Internet
serial.writelines("CHECK")
elif <CONDITION2>:
# Fetch something from the Internet
serial.writelines("STOP")
...
But, when my Arduino board receives this it receives the first message as INIT, but the second one is being read as INITSTOP or INITCHECK and third one gets concatenated to the previous messages. My arduino program checks for specific message in this way:
if(msg.equals("CHECK")) {
// Do something
}
else if(msg.equals("INIT")) {
// Do Something else
}
Can anyone guide me on this? BTW, I don't think the problem is with the Arduino as it works perfectly when I test it with the Serial Monitor available with the IDE.
I've tried adding sleeps of upto 10 seconds before every write, but that did not work out.
Try this this instead:
serial.write("INIT\r")
The writelines probably takes a list (but I can't check it now).

When listening for keypress in Flash Lite should I be listening for Key.Down or the numeric code for this key?

The adobe documentation says that when listening for a keypress event from a phone you should listen for Key.Down, however when I trace the Key.getCode() of keypresses I see a number not the string "Key.Down". I am tesing this locally in device central and do not have a phone to test this with at present. Here is my code -
keyListener = new Object();
keyListener.onKeyDown = function() {
switch (Key.getCode()) {
trace(Key.getCode()) // outputs 40
case (Key.DOWN) : // according to the docs
pressDown();
break;
}
}
My question is - is this simply because Im testing in device central and when I run it on the phone I will need to be listening for Key.Down? or is the documentation wrong? Also is the numeric code (40) consistent across all devices? What gives adobe?
thanks all
Key.Down is equal to 40 so it will recognize it as the same. So you can use whichever one you prefer, however, I would recommend using Key.Down because it will be easily recognizeable for those who dont have Key Codes memorized (most of us).
These are the Key Code Values for Javascript. However, I think they are pretty much universal

Resources