Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Hi Guys,
I want to do a program to pre-compute a list of rotated point coordinates
for a microcontroller that has no trig, and only integer math.
The easiest way for me to go right now, would be to do it on an iOS device.
In fact, the program is mostly already written for iPhone.

I have an iOS sample that removes the prefix from NSLog console,
so I was able to do some output once, and cut/paste it for a csv file.

Is there a way to send NSLog directly through a Mac's serial port?
I realise sending serial from the iOS device requires a jailbreak program,
but also suspect that NSLog strings are sent to Xcode through a USB
serial port from the test device.

I can cut and paste into a Windows terminal, and send data to the chip that way,
but directly from the Mac would be easier.
Cheers, Art.
 
Last edited:
You have access to a Mac. You can write the code to do this on iOS so can write Objective-C. Why can't you simply run that code on the Mac (as Mac OSX code)?
 
You have access to a Mac. You can write the code to do this on iOS so can write Objective-C. Why can't you simply run that code on the Mac (as Mac OSX code)?

It does seem the logical way, but it is whatever other learning curve
if any, I'd prefer to avoid.
I can't even pretend to be interested in desktop computers from a programmer's point of view,
but if it is that easy I should take a look.

I thought there might be some simple setting, but I can also see why there
might not be, since Xcode provides the console screen you'd normally be
using a serial port for.
 
It does seem the logical way, but it is whatever other learning curve
if any, I'd prefer to avoid.
I can't even pretend to be interested in desktop computers from a programmer's point of view,
but if it is that easy I should take a look.

I thought there might be some simple setting, but I can also see why there
might not be, since Xcode provides the console screen you'd normally be
using a serial port for.

I think it's an unusual enough demand that there is no such setting...
 
I think it's an unusual enough demand that there is no such setting...

I forgot it's a microcontroller at the receiving end.
I'll read a spot of light from the iPhone screen or camera flash :)
So long as it maintains framerate, sending the data is all it has to do at the time.
 
Ok, thanks, redirecting stdout to file... the site also brings to light the
reason why anyone else would care.

For jailbroken iPhone direct serial port you need at least a MAX232 or
similar powered level converter.
To read from the camera flash you would also minimally need one chip.

An App called iTorch Pro can strobe the camera flash accurately at a
variable rate between 1 - 29 Hz.

IT Crowd Season One DVD (Extras) reveals how to read the data they
have embedded into one of their episodes this way.

RS232 serial has less known standard baud rate 300 baud.

I think developer iDevice serial port is a done deal,
and additionally that nothing can be done about it.
The bit banging routine sending the data isn't the real serial port the platform's hackers want though.



The string you want to send to Mr Google is "redirect stdout MacOS" or something similar (without the quotes).

This might help:

http://stackoverflow.com/questions/...luding-uncaught-exceptions-nslog-calls-and-ot
 
The original issue I'd say is resolved, thanks.
There is some learning curve, but that is probably worth it.

In this thread I mentioned I was creating a csv file with NSlog.
I inserted the comma delimiters, etc, in the NSlog lines,
stripped the NSlog headers, so it could be cut and pasted.
It seems now, that an iOS device while connected to Xcode,
with no funny business, could directly produce the csv file (as a file).

Some unexpected learning.. I've got the serial USB dongle,
but have to learn how to find out whether or not the Mac knows it's there, etc.
 
Hi Guys,
I want to do a program to pre-compute a list of rotated point coordinates
for a microcontroller that has no trig, and only integer math.
The easiest way for me to go right now, would be to do it on an iOS device.
In fact, the program is mostly already written for iPhone.

I have an iOS sample that removes the prefix from NSLog console,
so I was able to do some output once, and cut/paste it for a csv file.

Is there a way to send NSLog directly through a Mac's serial port?
I realise sending serial from the iOS device requires a jailbreak program,
but also suspect that NSLog strings are sent to Xcode through a USB
serial port from the test device.

I can cut and paste into a Windows terminal, and send data to the chip that way,
but directly from the Mac would be easier.
Cheers, Art.

If you want formatted output, the C library function printf() is a better choice than NSLog. It does not included the prefix of each line. Remember that you need to add a "\n" at the end of each line.

You can also use sprintf() to build your output in a (C) string, or fprintf() to write your output directly to a file. To use fprintf() you would need to use C functions to open the file.

That code will be identical on both Mac and iOS, other than the pathnames you would write to.
 
Some unexpected learning.. I've got the serial USB dongle,
but have to learn how to find out whether or not the Mac knows it's there, etc.

What type of USB-to-serial adapter is it? There are two common chips used for this a Prolific PL2303, and an FTDI FT232.

You can usually identify the chip using System Information.app > USB, and then look for a serial device (aka UART).

Drivers for both chips are downloadable from the chip mfgrs and other places.

At the Terminal command-line, try this command:
Code:
ls -l /dev/cu.*
A "cu" device is the "calling unit" for a serial port, described here:
http://stackoverflow.com/questions/8632586/macos-whats-the-difference-between-dev-tty-and-dev-cu
 
What type of USB-to-serial adapter is it? There are two common chips used for this a Prolific PL2303, and an FTDI FT232.

Thanks, it does recognise that it is a Prolific chip.
I never installed the driver for Mac,
so maybe the latest update already knows about this chip.

the C library function printf() is a better choice than NSLog.

Thanks Duncan, I should have known that. I have another project with "Dlog",
which is just a redefined printf.

I didn't end up pre-computing points...
doing it for another platform might be cheating a bit for a demo.

Got Hack-A-Day front page feature with this :)

http://www.youtube.com/watch?v=1xq8xJqbkNA

There is difficulty in sending the framebuffer to a character LCD not designed for graphics.
Also, the 3D cube would have consumed the entire 2K chip,
and been the only section of the demo.
 
That was dumb..
Instead of sending the data over serial,
I might as well format the string that is sent with log
as a lookup table, or array declaration to paste directly into the other compiler.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.