Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing an "AT-Command" to a Modem




Am 23.10.2007 um 09:11 Uhr schrieb Stefan Lehrner:

what is the best way to send an "AT-Command" to a Modem?

There is no "best way". It depends on what you need.

Also, all “three ways“ you listed are very similar. AMSerialPort ist based on Apple's SerialPort sample. It just wraps the necessary procedures in Cocoa classes. And you can, of course, use the file handle returned from AMSerialPort -open to directly write to the serial device.

Am 23.10.2007 um 10:14 Uhr schrieb Half Activist:

Because I suppose you'll come across buffer problems with other methods and you'd run into data you write but never comes out to the serial port, and do quite a lot of flushing.

Why do you think so?

write( fd, [ yourData bytes ], [ yourData length ] );

Well, that's what AMSerialPort does:

- (BOOL)writeData:(NSData *)data error:(NSError **)error
{
	BOOL result = NO;

	const char *dataBytes = [data bytes];
	unsigned dataLen = [data length];
	ssize_t bytesWritten = 0;
	int errorCode = kAMSerialErrorNone;
	if (dataBytes && (dataLen > 0)) {
		bytesWritten = write(fileDescriptor, dataBytes, dataLen);

As I said: These “different ways“ are actually quite similar.


Andreas_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Writing an "AT-Command" to a Modem (From: Stefan Lehrner <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.