シリアルポートにデータを送信する必要があります。送信する内容の定義は次のとおりです。
Chr$(2) = Clear buffer
Chr$(48)&Chr(57) = Any number between 0 to 359
2090 の入力で失敗した試み
int i, c;
char j;
NSString *tmpStr = [self.sendTextField stringValue];
NSString *tmpVal;
for (i = 0 ; i < [tmpStr length]; i++)
{
NSLog(@"Iteration: %d", i);
tmpVal = [tmpStr substringWithRange:NSMakeRange(i, 1)];
c = [tmpVal intValue];
j = (char)c;
tmpVal = [NSString stringWithFormat:@"%c", j];
NSData *dataToSend = [tmpVal.value dataUsingEncoding:NSUTF8StringEncoding]; **<Error here**
[self.serialPort sendData:dataToSend];
}
コンソールが報告するエラーを修正する方法がわかりません。
2013-03-08 10:38:12.430 ORSSerialPortCocoaDemo[40656:303] Iteration: 0
2013-03-08 10:38:38.819 ORSSerialPortCocoaDemo[40656:303] -[__NSCFString value]: unrecognized selector sent to instance 0x1001626a0
2013-03-08 10:38:38.819 ORSSerialPortCocoaDemo[40656:303] -[__NSCFString value]: unrecognized selector sent to instance 0x1001626a0
2013-03-08 10:38:38.821 ORSSerialPortCocoaDemo[40656:303] (
0 CoreFoundation 0x00007fff858180a6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff835b03f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff858ae6ea -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
3 CoreFoundation 0x00007fff858065ce ___forwarding___ + 414
4 CoreFoundation 0x00007fff858063b8 _CF_forwarding_prep_0 + 232
5 ORSSerialPortCocoaDemo 0x0000000100008e81 -[ORSSerialPortDemoController send:] + 465
6 AppKit 0x00007fff868d6a59 -[NSApplication sendAction:to:from:] + 342
7 AppKit 0x00007fff868d68b7 -[NSControl sendAction:to:] + 85
8 AppKit 0x00007fff868d67eb -[NSCell _sendActionFrom:] + 138
9 AppKit 0x00007fff868d4cd3 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1855
10 AppKit 0x00007fff868d4521 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
11 AppKit 0x00007fff868d3c9c -[NSControl mouseDown:] + 820
12 AppKit 0x00007fff868cb60e -[NSWindow sendEvent:] + 6853
13 AppKit 0x00007fff868c7744 -[NSApplication sendEvent:] + 5761
14 AppKit 0x00007fff867dd2fa -[NSApplication run] + 636
15 AppKit 0x00007fff86781cb6 NSApplicationMain + 869
16 ORSSerialPortCocoaDemo 0x0000000100001d62 main + 34
17 ORSSerialPortCocoaDemo