Serial Port not working on Mac

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Serial Port not working on Mac

Guillermo Polito
 
Hi all,

We are here with Olivier taking a loot at how serial ports work, because he wants to use it to connect to arduino/raspberries.

We saw that the serial port works nice in unix, in windows we had a look but we found some problems (and we do not have now a windows machine to test well), and we found that in mac it does not work. We are seeing that this behaviour is there since Pharo 3 (4 years ago).

We tried to see if it was a problem of the VM plugin (missing depenencies using ld / otool) but everything seemed ok.

Finally, we took the vm from git and tried to compile it from scratch.

Meta-question 1: Is there a way to create an xcode project from the vm sources? We would have lost less time if we used a graphical debugger to take a look at this :).

There, we found that
- apparently the mac VM is using an empty implementation of the serial port plugin:


We replaced the contents of that file by the one in the Unix plugin and it worked when the plugin was compiled as internal (delta some differences between the default values in mac and unix like uppercasing the 's' of ttyS and ttys) 


However, as soon as we retried to recompile the plugin as external it did not work any more... The initializeModule function was never called, the module was not loaded (from the system report) and the Serial port could not be open. For this we would have liked a debugger. And I'm not a friend of gdb on the terminal...

Meta-question 2: Is there any clean/make clean used to remove generated files. We found ourselves a lot of times bitten by the fact that even recompiling everything using `mvm -A` did not really recompile and we had to remove files from here and there...

How should we propose a fix?
- do we duplicate the code of the plugin in the mac and unix platforms?
- or do we somehow tell the compilation process that for this plugin it should use the sources in the unix platform code?

Thanks!
Guille and Olivier
Reply | Threaded
Open this post in threaded view
|

Re: Serial Port not working on Mac

EstebanLM
 

On 24 Mar 2017, at 15:07, Guillermo Polito <[hidden email]> wrote:

Hi all,

We are here with Olivier taking a loot at how serial ports work, because he wants to use it to connect to arduino/raspberries.

We saw that the serial port works nice in unix, in windows we had a look but we found some problems (and we do not have now a windows machine to test well), and we found that in mac it does not work. We are seeing that this behaviour is there since Pharo 3 (4 years ago).

We tried to see if it was a problem of the VM plugin (missing depenencies using ld / otool) but everything seemed ok.

Finally, we took the vm from git and tried to compile it from scratch.

Meta-question 1: Is there a way to create an xcode project from the vm sources? We would have lost less time if we used a graphical debugger to take a look at this :).

No. What you do is to create an empty project and then attaching the running vm. 

Esteban


There, we found that
- apparently the mac VM is using an empty implementation of the serial port plugin:


We replaced the contents of that file by the one in the Unix plugin and it worked when the plugin was compiled as internal (delta some differences between the default values in mac and unix like uppercasing the 's' of ttyS and ttys) 


However, as soon as we retried to recompile the plugin as external it did not work any more... The initializeModule function was never called, the module was not loaded (from the system report) and the Serial port could not be open. For this we would have liked a debugger. And I'm not a friend of gdb on the terminal...

Meta-question 2: Is there any clean/make clean used to remove generated files. We found ourselves a lot of times bitten by the fact that even recompiling everything using `mvm -A` did not really recompile and we had to remove files from here and there...

How should we propose a fix?
- do we duplicate the code of the plugin in the mac and unix platforms?
- or do we somehow tell the compilation process that for this plugin it should use the sources in the unix platform code?

Thanks!
Guille and Olivier

Reply | Threaded
Open this post in threaded view
|

Re: Serial Port not working on Mac

Javier Diaz-Reinoso
 
There is Apple documentation for this in:
https://developer.apple.com/library/content/documentation/Porting/Conceptual/PortingUnix/preparing/preparing.html

On 24 Mar 2017, at 09:13, Esteban Lorenzano <[hidden email]> wrote:


On 24 Mar 2017, at 15:07, Guillermo Polito <[hidden email]> wrote:

Hi all,

We are here with Olivier taking a loot at how serial ports work, because he wants to use it to connect to arduino/raspberries.

We saw that the serial port works nice in unix, in windows we had a look but we found some problems (and we do not have now a windows machine to test well), and we found that in mac it does not work. We are seeing that this behaviour is there since Pharo 3 (4 years ago).

We tried to see if it was a problem of the VM plugin (missing depenencies using ld / otool) but everything seemed ok.

Finally, we took the vm from git and tried to compile it from scratch.

Meta-question 1: Is there a way to create an xcode project from the vm sources? We would have lost less time if we used a graphical debugger to take a look at this :).

No. What you do is to create an empty project and then attaching the running vm. 

Esteban


There, we found that
- apparently the mac VM is using an empty implementation of the serial port plugin:


We replaced the contents of that file by the one in the Unix plugin and it worked when the plugin was compiled as internal (delta some differences between the default values in mac and unix like uppercasing the 's' of ttyS and ttys) 


However, as soon as we retried to recompile the plugin as external it did not work any more... The initializeModule function was never called, the module was not loaded (from the system report) and the Serial port could not be open. For this we would have liked a debugger. And I'm not a friend of gdb on the terminal...

Meta-question 2: Is there any clean/make clean used to remove generated files. We found ourselves a lot of times bitten by the fact that even recompiling everything using `mvm -A` did not really recompile and we had to remove files from here and there...

How should we propose a fix?
- do we duplicate the code of the plugin in the mac and unix platforms?
- or do we somehow tell the compilation process that for this plugin it should use the sources in the unix platform code?

Thanks!
Guille and Olivier

Reply | Threaded
Open this post in threaded view
|

Re: Serial Port not working on Mac

johnmci
 
BTW there is the SerialExtendedUnixPlugin which I wrote back in 2003. Check the mail list archives for threads on running it on OS X as it exposes why more fiddly bits of the Unix serial I/O logic. 

On Fri, Mar 24, 2017 at 8:13 AM, Javier Diaz-Reinoso <[hidden email]> wrote:
 
There is Apple documentation for this in:
https://developer.apple.com/library/content/documentation/Porting/Conceptual/PortingUnix/preparing/preparing.html

On 24 Mar 2017, at 09:13, Esteban Lorenzano <[hidden email]> wrote:


On 24 Mar 2017, at 15:07, Guillermo Polito <[hidden email]> wrote:

Hi all,

We are here with Olivier taking a loot at how serial ports work, because he wants to use it to connect to arduino/raspberries.

We saw that the serial port works nice in unix, in windows we had a look but we found some problems (and we do not have now a windows machine to test well), and we found that in mac it does not work. We are seeing that this behaviour is there since Pharo 3 (4 years ago).

We tried to see if it was a problem of the VM plugin (missing depenencies using ld / otool) but everything seemed ok.

Finally, we took the vm from git and tried to compile it from scratch.

Meta-question 1: Is there a way to create an xcode project from the vm sources? We would have lost less time if we used a graphical debugger to take a look at this :).

No. What you do is to create an empty project and then attaching the running vm. 

Esteban


There, we found that
- apparently the mac VM is using an empty implementation of the serial port plugin:


We replaced the contents of that file by the one in the Unix plugin and it worked when the plugin was compiled as internal (delta some differences between the default values in mac and unix like uppercasing the 's' of ttyS and ttys) 


However, as soon as we retried to recompile the plugin as external it did not work any more... The initializeModule function was never called, the module was not loaded (from the system report) and the Serial port could not be open. For this we would have liked a debugger. And I'm not a friend of gdb on the terminal...

Meta-question 2: Is there any clean/make clean used to remove generated files. We found ourselves a lot of times bitten by the fact that even recompiling everything using `mvm -A` did not really recompile and we had to remove files from here and there...

How should we propose a fix?
- do we duplicate the code of the plugin in the mac and unix platforms?
- or do we somehow tell the compilation process that for this plugin it should use the sources in the unix platform code?

Thanks!
Guille and Olivier





--
===========================================================================
John M. McIntosh. Corporate Smalltalk Consulting Ltd https://www.linkedin.com/in/smalltalk
===========================================================================
Reply | Threaded
Open this post in threaded view
|

Re: Serial Port not working on Mac

David T. Lewis
 
On Fri, Mar 24, 2017 at 08:58:50AM -0700, John McIntosh wrote:
>  
> BTW there is the SerialExtendedUnixPlugin which I wrote back in 2003. Check
> the mail list archives for threads on running it on OS X as it exposes why
> more fiddly bits of the Unix serial I/O logic.

We have this:

http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/platforms/Mac%20OS/plugins/SerialExtendedPlugin/

Is there Smalltalk (slang) that goes with it for generating the plugin?

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Serial Port not working on Mac

johnmci
 
yes the *.c file is generated by slang, let me attach the *.c files I have from an archive, but that likely won't work as it's not generated as 64bit clean


On Fri, Mar 24, 2017 at 5:07 PM, David T. Lewis <[hidden email]> wrote:

On Fri, Mar 24, 2017 at 08:58:50AM -0700, John McIntosh wrote:
>
> BTW there is the SerialExtendedUnixPlugin which I wrote back in 2003. Check
> the mail list archives for threads on running it on OS X as it exposes why
> more fiddly bits of the Unix serial I/O logic.

We have this:

http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/platforms/Mac%20OS/plugins/SerialExtendedPlugin/

Is there Smalltalk (slang) that goes with it for generating the plugin?

Dave





--
===========================================================================
John M. McIntosh. Corporate Smalltalk Consulting Ltd https://www.linkedin.com/in/smalltalk
===========================================================================

SerialExtendedUnixPlugin.c (25K) Download Attachment
sqMacSerialExtended.c (15K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Serial Port not working on Mac

johnmci
 
Also I guess the current corrected changes set 

On Fri, Mar 24, 2017 at 5:32 PM, John McIntosh <[hidden email]> wrote:
yes the *.c file is generated by slang, let me attach the *.c files I have from an archive, but that likely won't work as it's not generated as 64bit clean


On Fri, Mar 24, 2017 at 5:07 PM, David T. Lewis <[hidden email]> wrote:

On Fri, Mar 24, 2017 at 08:58:50AM -0700, John McIntosh wrote:
>
> BTW there is the SerialExtendedUnixPlugin which I wrote back in 2003. Check
> the mail list archives for threads on running it on OS X as it exposes why
> more fiddly bits of the Unix serial I/O logic.

We have this:

http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/platforms/Mac%20OS/plugins/SerialExtendedPlugin/

Is there Smalltalk (slang) that goes with it for generating the plugin?

Dave





--
===========================================================================
John M. McIntosh. Corporate Smalltalk Consulting Ltd https://www.linkedin.com/in/smalltalk
===========================================================================



--
===========================================================================
John M. McIntosh. Corporate Smalltalk Consulting Ltd https://www.linkedin.com/in/smalltalk
===========================================================================

EnhancedSerialPorts-JMM.11wSmalltalkFixesFor3.10-kgb.cs-M6966.txt.zip (24K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Serial Port not working on Mac

David T. Lewis
 
Thanks John!

Dave

On Fri, Mar 24, 2017 at 05:38:00PM -0700, John McIntosh wrote:

>  
> Also I guess the current corrected changes set
>
> On Fri, Mar 24, 2017 at 5:32 PM, John McIntosh <
> [hidden email]> wrote:
>
> > yes the *.c file is generated by slang, let me attach the *.c files I have
> > from an archive, but that likely won't work as it's not generated as 64bit
> > clean
> >
> >
> > On Fri, Mar 24, 2017 at 5:07 PM, David T. Lewis <[hidden email]>
> > wrote:
> >
> >>
> >> On Fri, Mar 24, 2017 at 08:58:50AM -0700, John McIntosh wrote:
> >> >
> >> > BTW there is the SerialExtendedUnixPlugin which I wrote back in 2003.
> >> Check
> >> > the mail list archives for threads on running it on OS X as it exposes
> >> why
> >> > more fiddly bits of the Unix serial I/O logic.
> >>
> >> We have this:
> >>
> >> http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/platform
> >> s/Mac%20OS/plugins/SerialExtendedPlugin/
> >>
> >> Is there Smalltalk (slang) that goes with it for generating the plugin?
> >>
> >> Dave
> >>
> >>
> >>
> >
> >
> > --
> > ============================================================
> > ===============
> > John M. McIntosh. Corporate Smalltalk Consulting Ltd
> > https://www.linkedin.com/in/smalltalk
> > ============================================================
> > ===============
> >
>
>
>
> --
> ===========================================================================
> John M. McIntosh. Corporate Smalltalk Consulting Ltd
> https://www.linkedin.com/in/smalltalk
> ===========================================================================


Reply | Threaded
Open this post in threaded view
|

Re: Serial Port not working on Mac

timrowledge
In reply to this post by Guillermo Polito
 

> On 24-03-2017, at 7:07 AM, Guillermo Polito <[hidden email]> wrote:
>
> Hi all,
>
> We are here with Olivier taking a loot at how serial ports work, because he wants to use it to connect to arduino/raspberries.

In the case of Pi’s don’t forget that there are much faster ways to connect; even the oldest Pi’s have ethernet and Pi3’s have wifi & bluetooth built in. Opening a net connection to a Pi is likely to be much more useful than restricting yourself to serial. I’m sure you’re not making the mistake I see too often of people thinking a Pi is a microcontroller like an Arduino when it is actually a quite powerful computer with a real OS...


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Hard work pays off in the future. Laziness pays off now.


Reply | Threaded
Open this post in threaded view
|

Re: Serial Port not working on Mac

Guillermo Polito
 
Hi all, thanks for the answers,

First, we managed to debug the VM using Xcode (thanks Esteban :)).
We found that when the serial plugin is compiled as external plugin in Mac, the VM does not load it because it cannot find the setInterpreter function, which is strange. We will continue digging here... 

John, 
I checked the code of sqMacSerialExtended and uses Carbon libraries. 
Isn't the VM moving out from it because it's not supported any more?
Besides, in Mac we can use unix libraries like termios...

Tim,
Yes, we know. We just wanted to do a tutorial on playing with arduino and we saw that the serial plugin was not working... We thing that independently of what we are doing with it, serial port should be fixed :)

Guille

On Tue, Mar 28, 2017 at 2:08 AM, tim Rowledge <[hidden email]> wrote:


> On 24-03-2017, at 7:07 AM, Guillermo Polito <[hidden email]> wrote:
>
> Hi all,
>
> We are here with Olivier taking a loot at how serial ports work, because he wants to use it to connect to arduino/raspberries.

In the case of Pi’s don’t forget that there are much faster ways to connect; even the oldest Pi’s have ethernet and Pi3’s have wifi & bluetooth built in. Opening a net connection to a Pi is likely to be much more useful than restricting yourself to serial. I’m sure you’re not making the mistake I see too often of people thinking a Pi is a microcontroller like an Arduino when it is actually a quite powerful computer with a real OS...


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Hard work pays off in the future. Laziness pays off now.



Reply | Threaded
Open this post in threaded view
|

Re: Serial Port not working on Mac

timrowledge
 

> On 28-03-2017, at 7:44 AM, Guillermo Polito <[hidden email]> wrote:
>
> Tim,
> Yes, we know. We just wanted to do a tutorial on playing with arduino and we saw that the serial plugin was not working... We thing that independently of what we are doing with it, serial port should be fixed :)

Absolutely. Serial ports that don’t work are not terribly helpful.

You’d be amazed how often I do see people asking effectively “how do I program a raspberrianpie? I can’t find Arduino libraries for it”. Of course they tend to be the same sort of people that try to tell me that linux can only run on x86 machines, that Apple stole linux and tried to make it closed source but Microsoft bravely fought them off, that Harley’s are motorcycles, and that C++ was predicted by {religious tract of their choice}, etc.

Ooh, look; my random sigline chooser found an amazingly apropos sigline to describe such people!

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Useful random insult:- Solid concrete from the eyebrows backwards.