Code: Select all
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
if (Serial.available() > 0) {
Serial.println("<DMX>255,23,1,4,6</DMX>");
delay(2000);
Serial.println("<DMX>9,44,88,238,90</DMX>");
delay(2000);
}
}
Any ideas on how to fix this? Is it even possible? If not, any work arounds on either side (Arduino, mac)?
Thanks,
Elijah
P.S. - if anyone knows Obj-c here is the didReceiveData method on the mac side. I was trying to see if I could handle the chunks, but I'm having some trouble. That's why I thought I'd ask here to see if I can get the root of the problem on the Arduino side.
Code: Select all
- (void) didReceiveData:(NSString *)data {
// status=0 means we are still looking for start tag
if(status == 0) {
// add new data to last examined chunk (if any)
[tmpBuffer appendString:data];
// try to locate the open tag inside the tmpBuffer
NSRange range = [tmpBuffer rangeOfString:@"<DMX>" options:NSCaseInsensitiveSearch];
// if found, store the portion after the start tag into buffer
if(range.location != NSNotFound) {
range.length = [tmpBuffer length] - range.location + 5; // 5 is length of start tag...
[buffer setString:[tmpBuffer substringWithRange:range]];
status = 1; // set status to 1 so we know recording started
} else {
// store last examined chunk
[tmpBuffer setString:data];
}
} else {
[buffer appendString:data];
NSRange range = [buffer rangeOfString:@"</DMX>" options:NSCaseInsensitiveSearch];
if(range.location != NSNotFound) {
range.length = [buffer length] - range.location;
NSRunAlertPanel(@"", [NSString stringWithString: buffer], @"", @"", @"");
[buffer BANNED:range];
status = 0;
}
}
}