| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Stefan,
NSData *yourData; NSString *yourPath = ...;
int fd = open( [ yourPath UTF8String ], O_WRONLY, S_IRUSR );
if( fd == -1 ){
... something wrong happened ... check for errno
}... fill/create a valid NSData instance ... write( fd, [ yourData bytes ], [ yourData length ] );
...
close( fd );
Regards.
On Oct 23, 2007, at 9:45 AM, Stefan Lehrner wrote:
Hi Half Activist,
thanks for your help! So you would suggest me, to use the 3rd choice?
Thanks again for your help!
Stefan
On Tuesday, October 23, 2007, at 12:36AM, "Half Activist" <email@hidden> wrote:Hi Stefan,
there's something wrong in your third choice. this should be something like that:
NSData *yourData; NSString *yourPath = ...;
NSFileHandle *fileHandle = [ NSFileHandle fileHandleForUpdatingAtPath: yourPath ];
... fill/create a valid NSData instance ...
[ fileHandle writeData: yourData ];
...
[ fileHandle closeFile ];
Regards
On Oct 23, 2007, at 9:11 AM, Stefan Lehrner wrote:
Hi Folks,
what is the best way to send an "AT-Command" to a Modem?
I found several ways on the Internet:
1) SerialPort Sample of Apple
// Now open the modem port we found, initialize the modem, then close it if (!bsdPath[0]) { printf("No modem port found.\n"); return EX_UNAVAILABLE; }
fileDescriptor = OpenSerialPort(bsdPath); if (-1 == fileDescriptor) { return EX_IOERR; }
if (InitializeModem(fileDescriptor)) { printf("Modem initialized successfully.\n"); } else { printf("Could not initialize modem.\n"); }
2) AMSerialTest
NSString *sendString = [[inputTextField stringValue] stringByAppendingString:@"\r"];
if(!port) { // open a new port if we don't already have one [self initPort]; }
if([port isOpen]) { // in case an error occured while opening the port [port writeString:sendString usingEncoding:NSUTF8StringEncoding error:NULL]; }
3) NSFileHandle
myPath = modempath; writeFile = [NSFileHandle fileHandleForUpdatingAtPath]; [writeFile writeData:myPath];
It looks like, that the 3rd one would be the easiest way - but where shall I put the "at-commands" there?
Thanks for your hints and tipps...
BR
Stefan _______________________________________________
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/halfactivist% 40gmail.com
This email sent to email@hidden
_______________________________________________
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
| References: | |
| >Writing an "AT-Command" to a Modem (From: Stefan Lehrner <email@hidden>) | |
| >Re: Writing an "AT-Command" to a Modem (From: Half Activist <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.