IOBluetoothRFCOMMChannel writeSync:length: hangs or crashes
IOBluetoothRFCOMMChannel writeSync:length: hangs or crashes
- Subject: IOBluetoothRFCOMMChannel writeSync:length: hangs or crashes
- From: Jan-Felix Schwarz <email@hidden>
- Date: Mon, 21 Dec 2009 13:38:54 +0100
Hi,
I have the following method that writes AT commands to a RFCOMM channel:
- (void) sendData:(NSString *)string toChannel:(IOBluetoothRFCOMMChannel*)rfcommChannel
{
int i;
// Turn the string into data.
NSData *data = [string dataUsingEncoding:NSASCIIStringEncoding];
char buffer[ [data length] +4];
char *bytes = (char *) [data bytes];
// Add a CRLF to the start
buffer[0] = 13;
buffer[1] = 10;
// Copy the data into the buffer.
for (i=0;i<[data length];i++)
{
buffer[2+i] = bytes[i];
}
// Append a CRLF
buffer[ [data length]+2] = 13;
buffer[ [data length]+3] = 10;
// Synchronously write the data to the channel.
[rfcommChannel writeSync:&buffer length:[data length]+4];
}
That works fine in most cases, but sometimes the call of writeSync:length: takes around 5 seconds while my program is in busy waiting. Sometimes the whole system even crashes during the call of writeSync:length: and I have to hard-reset my MacBook:( I cannot find anything in the logs.
Did anyone on the list experience problems like that? I have OS 10.6.2 installed and the version of the Apple Bluetooth Software is 2.2.4f3.
Thanks for your help,
Jan _______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden