Connect to serial device Obj-C

Discussion in 'Mac Programming' started by varlos101, Aug 19, 2010.

  1. varlos101 macrumors newbie

    Joined:
    Aug 19, 2010
    Location:
    Washington
    #1
    This is my first program and I really don't have any experience with any language other than HTML and JavaScript. It needs to communicate with a serial device, but after reading online a while I haven't found any good way to go about this. I need my program to connect to /dev/tty.Icon322\ Control and then send it AT+CSQ. It will then return something like this:
    Code:
    +CSQ: 14,0
    
    OK
    
    I then need to set the 14 to an int called RSSI. Once I can do this, then I can do other things such as SIM PIN and initiate a data connection to have internet with AT+CGACT=1,1 ect.

    So far everything works without any errors or warnings, here is what I have so far:
    Code:
    - (IBAction)getSignalStrength:(id)sender{
    	/*
    	 Here comes the hard part, this is where it checks the signal from the device.
    	*/
    	int RSSI = ;//The signal that is retrieved.
    	int calculatedSignal = RSSI * 2 - 113;
    	[signalStrength setIntValue:(int)calculatedSignal];
    	
    	fivebars = [NSImage imageNamed:@"fivebars.png"];
    	fourbars = [NSImage imageNamed:@"fourbars.png"];
    	threebars = [NSImage imageNamed:@"threebars.png"];
    	twobars = [NSImage imageNamed:@"twobars.png"];
    	onebar = [NSImage imageNamed:@"onebar.png"];
    	
    	if (calculatedSignal < -106) {
    		[imageView setImage:(NSImage *)onebar];
    	}
    	else if (calculatedSignal < -98) {
    		[imageView setImage:(NSImage *)twobars];
    	}
    	else if (calculatedSignal < -90) {
    		[imageView setImage:(NSImage *)threebars];
    	}
    	else if (calculatedSignal < -82) {
    		[imageView setImage:(NSImage *)fourbars];
    	}
    	else if (calculatedSignal > -82) {
    		[imageView setImage:(NSImage *)fivebars];
    	}
    }
    
     
  2. varlos101 thread starter macrumors newbie

    Joined:
    Aug 19, 2010
    Location:
    Washington
    #3
    Thanks, this is exactly what I was looking for!
     

Share This Page