SerialPort on Raspberry Pi

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

SerialPort on Raspberry Pi

Jon Hylands

Hi everyone,

I'm trying to use the SerialPort class on my Raspberry pi 2, to access the UART on the pi.

I've successfully accessed the port from python, using pyserial. On the pi, the port name is '/dev/ttyAMA0'.

In squeak (using the 5.0 all-in-one), when I try and open the port, it fails, but doesn't tell you anything useful.

After I attempt to open the port, SerialPlugin is listed both as an internal plugin and as a loaded module.

SerialPlugin VMMaker.oscog-eem.1325 (i)

Has anyone actually used the serial port on the pi from Squeak?

Thanks,
Jon




Reply | Threaded
Open this post in threaded view
|

Re: SerialPort on Raspberry Pi

timrowledge

> On 14-01-2016, at 5:51 AM, Jon Hylands <[hidden email]> wrote:
>
>
> Hi everyone,
>
> I'm trying to use the SerialPort class on my Raspberry pi 2, to access the UART on the pi.
>
> I've successfully accessed the port from python, using pyserial. On the pi, the port name is '/dev/ttyAMA0’.

The only thing I can offer is that Scratch finds a serial port as /dev/ttyAMA0 as well, implying that on at least one Pi it finds the same port that python does. I don’t think I have any devices that I could even try to connect to. Any suggestions for things that might be around the office?

I do faintly recall some discussions about Pi serial stuff and having to use the rasp-config utility but that was a long time ago and I don’t seem to have any emails referring to it.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Strange OpCodes: EOS: Erase Operating System



Reply | Threaded
Open this post in threaded view
|

Re: SerialPort on Raspberry Pi

Ben Coman
On Mon, Jan 18, 2016 at 7:38 AM, tim Rowledge <[hidden email]> wrote:

>
>> On 14-01-2016, at 5:51 AM, Jon Hylands <[hidden email]> wrote:
>>
>>
>> Hi everyone,
>>
>> I'm trying to use the SerialPort class on my Raspberry pi 2, to access the UART on the pi.
>>
>> I've successfully accessed the port from python, using pyserial. On the pi, the port name is '/dev/ttyAMA0’.
>
> The only thing I can offer is that Scratch finds a serial port as /dev/ttyAMA0 as well, implying that on at least one Pi it finds the same port that python does. I don’t think I have any devices that I could even try to connect to. Any suggestions for things that might be around the office?
>
> I do faintly recall some discussions about Pi serial stuff and having to use the rasp-config utility but that was a long time ago and I don’t seem to have any emails referring to it.
>
>
> tim
> --
> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> Strange OpCodes: EOS: Erase Operating System
>
>
>

Maybe you could just loop back...
http://unix.stackexchange.com/questions/117037/how-to-send-data-to-a-serial-port-and-see-any-answer

Reply | Threaded
Open this post in threaded view
|

Re: SerialPort on Raspberry Pi

Ben Coman
On Mon, Jan 18, 2016 at 8:35 AM, Ben Coman <[hidden email]> wrote:

> On Mon, Jan 18, 2016 at 7:38 AM, tim Rowledge <[hidden email]> wrote:
>>
>>> On 14-01-2016, at 5:51 AM, Jon Hylands <[hidden email]> wrote:
>>>
>>>
>>> Hi everyone,
>>>
>>> I'm trying to use the SerialPort class on my Raspberry pi 2, to access the UART on the pi.
>>>
>>> I've successfully accessed the port from python, using pyserial. On the pi, the port name is '/dev/ttyAMA0’.
>>
>> The only thing I can offer is that Scratch finds a serial port as /dev/ttyAMA0 as well, implying that on at least one Pi it finds the same port that python does. I don’t think I have any devices that I could even try to connect to. Any suggestions for things that might be around the office?
>>
>> I do faintly recall some discussions about Pi serial stuff and having to use the rasp-config utility but that was a long time ago and I don’t seem to have any emails referring to it.
>>
>>
>> tim
>> --
>> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
>> Strange OpCodes: EOS: Erase Operating System
>>
>>
>>
>
> Maybe you could just loop back...
> http://unix.stackexchange.com/questions/117037/how-to-send-data-to-a-serial-port-and-see-any-answer

Whoops, sent too soon - just a potential problem...
http://unix.stackexchange.com/questions/42964/unexpected-results-testing-serial-loopback-using-echo-and-cat

Loopback with SoCat
http://myrobotlab.org/content/serial-terminal-loopbacks-linux

Hardware loopback
http://serial-lines.blogspot.com.au/2011/04/for-this-post-were-going-to-send-some.html

Toubleshooting...
http://www.ee.ryerson.ca/~phiscock/papers/serial.pdf

cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: SerialPort on Raspberry Pi

Jon Hylands
In reply to this post by timrowledge
You don't need a device to test it - Serial doesn't require a second device if all you're doing is sending bytes.

The issue I'm having is when I try and open the port - that part is failing.

Tim, not sure if you have Scratch set up to access the underlying Squeak code, but if you do:

| serialPort |
serialPort := SerialPort new.
serialPort baudrate: 115200.
serialPort openPort: '/dev/ttyAMA0'.
serialPort inspect

the port instance variable in serialPort will be nil if it failed, and something else if it didn't fail.

Thanks,
Jon


On Sun, Jan 17, 2016 at 6:38 PM, tim Rowledge <[hidden email]> wrote:

> On 14-01-2016, at 5:51 AM, Jon Hylands <[hidden email]> wrote:
>
>
> Hi everyone,
>
> I'm trying to use the SerialPort class on my Raspberry pi 2, to access the UART on the pi.
>
> I've successfully accessed the port from python, using pyserial. On the pi, the port name is '/dev/ttyAMA0’.

The only thing I can offer is that Scratch finds a serial port as /dev/ttyAMA0 as well, implying that on at least one Pi it finds the same port that python does. I don’t think I have any devices that I could even try to connect to. Any suggestions for things that might be around the office?

I do faintly recall some discussions about Pi serial stuff and having to use the rasp-config utility but that was a long time ago and I don’t seem to have any emails referring to it.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Strange OpCodes: EOS: Erase Operating System






Reply | Threaded
Open this post in threaded view
|

Re: SerialPort on Raspberry Pi

Herbert König
Hi Jon,

it used to work exactly like this.

I have two methods from March 2015 to control a servo controller via RS232C. One is:
initSystem
    (self serialPortName: '/dev/ttyAMA0') ifNil: [0 halt "can't init serial port"].
    self getErrors
which calls:
serialPortName: aString
    "return nil if opening failed"
    ^serial openPort: aString
and in initialize I do:
initialize
    "super uses two SerialPorts, so no super initialize here"
    serial := SerialPort new.
    serial baudRate: 115200.
    serialCommand := serial.

No access to my Pi's I just copied this from a backup of the Squeak 4.5 image with the old VM which I have on my laptop. I haven't used this software since last October (youngest method stamp). So maybe one of the raspbian updates broke it or the new VM or image need different incantations. I didn't use sudo but missing access rights can also cause problems.

Cheers,

Herbert

So maybe you try on 4.5 and the old VM.

Am 18.01.2016 um 13:50 schrieb Jon Hylands:
You don't need a device to test it - Serial doesn't require a second device if all you're doing is sending bytes.

The issue I'm having is when I try and open the port - that part is failing.

Tim, not sure if you have Scratch set up to access the underlying Squeak code, but if you do:

| serialPort |
serialPort := SerialPort new.
serialPort baudrate: 115200.
serialPort openPort: '/dev/ttyAMA0'.
serialPort inspect

the port instance variable in serialPort will be nil if it failed, and something else if it didn't fail.

Thanks,
Jon


On Sun, Jan 17, 2016 at 6:38 PM, tim Rowledge <[hidden email]> wrote:

> On 14-01-2016, at 5:51 AM, Jon Hylands <[hidden email]> wrote:
>
>
> Hi everyone,
>
> I'm trying to use the SerialPort class on my Raspberry pi 2, to access the UART on the pi.
>
> I've successfully accessed the port from python, using pyserial. On the pi, the port name is '/dev/ttyAMA0’.

The only thing I can offer is that Scratch finds a serial port as /dev/ttyAMA0 as well, implying that on at least one Pi it finds the same port that python does. I don’t think I have any devices that I could even try to connect to. Any suggestions for things that might be around the office?

I do faintly recall some discussions about Pi serial stuff and having to use the rasp-config utility but that was a long time ago and I don’t seem to have any emails referring to it.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Strange OpCodes: EOS: Erase Operating System







    



Reply | Threaded
Open this post in threaded view
|

Re: SerialPort on Raspberry Pi

timrowledge
It’s probably well worth comparing platforms/unix/plugins/SerialPlugin/sqUnixSerial.c & platforms/unix/plugins/ScratchPlugin/unixSerialPort2Ops.c

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Ornerythologists study bad tempered birds