Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 通过TCP在流上写入但没有响应_Objective C_Tcp_Stream_Obd Ii - Fatal编程技术网

Objective c 通过TCP在流上写入但没有响应

Objective c 通过TCP在流上写入但没有响应,objective-c,tcp,stream,obd-ii,Objective C,Tcp,Stream,Obd Ii,我想通过OBD WiFi适配器读取汽车的车辆识别号(VIN)。 ping适配器是可能的,它得到了一个固定的IP地址和端口 现在我想在流上发送VIN请求,但什么也没发生 我的.h文件 @interface Communicator : NSObject <NSStreamDelegate> { @public NSString *host; int port; } - (void)setup; - (void)open; - (void)close; - (void)stream:

我想通过OBD WiFi适配器读取汽车的车辆识别号(VIN)。 ping适配器是可能的,它得到了一个固定的IP地址和端口

现在我想在流上发送VIN请求,但什么也没发生

我的.h文件

@interface Communicator : NSObject <NSStreamDelegate> {
@public

NSString *host;
int port;
}

- (void)setup;
- (void)open;
- (void)close;
- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)event;
- (void)readIn:(NSString *)s;
- (void)writeOut:(NSString *)s;

@end
我的主要

@autoreleasepool {

Communicator *c = [[Communicator alloc] init];

c->host = @"https://169.254.1.10";
//c->host = @"http://169.254.1.10";
//c->host = @"169.254.1.10";
c->port = 23;

[c setup];
[c open];

[c writeOut:@"0902"];

do {
} while (1);

         }
return 0;
}
控制台说:

2012-12-13 16:22:41.319 obdlink[1940:f803] Setting up connection to https://169.254.1.10 : 23
2012-12-13 16:22:55.409 obdlink[1940:f803] Opening streams.
2012-12-13 16:23:16.504 obdlink[1940:f803] Status of outputStream: 1
2012-12-13 16:23:20.878 obdlink[1940:f803] Opening streams.
2012-12-13 16:23:33.858 obdlink[1940:f803] Status of outputStream: 2
2012-12-13 16:23:46.092 obdlink[1940:f803] Error: (null)
2012-12-13 16:23:59.011 obdlink[1940:f803] Writing out the following:
2012-12-13 16:24:01.104 obdlink[1940:f803] 0902
“0902”是应返回带有VIN的5x5多帧响应的命令

我真的尝试了我能想象的一切,或者我在万维网上找到的一切。
我被卡住了,无法进一步了解,我希望这里的任何人都能帮助我。

随便猜一猜,你需要在字符串末尾发送一个CRLF以获得响应。这是一个基于telnet的协议,因此您应该通过执行
telnet 169.254.1.10
并在
提示符下键入命令来验证它是否有效。@Petesh thx,请回答。不幸的是,CRLF没有帮助。仍然没有回应。但是我可以验证它是否与telnet一起工作,并且我在提示符上得到了预期的结果。您可能需要执行适当的telnet握手,以获得预期的响应。在这个答案中,有人试图在目标c中实现telnet连接-我不知道有任何现成的(免费)类会自动为您实现这一点,但实现它并不困难。再次为链接执行thx。我试试看,不过需要一些时间。这个周末我几乎没有时间。请继续看这篇文章,并尽快回复,这对我帮助很大。如果我得到一些结果,我会尽快回复。对不起,耽搁了。圣诞节打乱了我的计划。我希望我能在周末之前找到你的答案/猜测。敬请期待。
2012-12-13 16:22:41.319 obdlink[1940:f803] Setting up connection to https://169.254.1.10 : 23
2012-12-13 16:22:55.409 obdlink[1940:f803] Opening streams.
2012-12-13 16:23:16.504 obdlink[1940:f803] Status of outputStream: 1
2012-12-13 16:23:20.878 obdlink[1940:f803] Opening streams.
2012-12-13 16:23:33.858 obdlink[1940:f803] Status of outputStream: 2
2012-12-13 16:23:46.092 obdlink[1940:f803] Error: (null)
2012-12-13 16:23:59.011 obdlink[1940:f803] Writing out the following:
2012-12-13 16:24:01.104 obdlink[1940:f803] 0902