Shop OBEX P1 Docs P2 Docs Learn Events
Propberry — Parallax Forums

Propberry

HughWNHughWN Posts: 8
edited 2023-11-19 10:05 in Propeller 1

Ages and ages ago there was a thread on combining a Prop 1 and a Raspberry Pi (related to this). Has anyone managed to do something similar, i.e., sending serial data from the P1 to Pi and might be able to give some pointers?

I'm happy on the Prop end and using FullDuplexSerial (presumably //ttyUSB0 on the Pi uses pins 31 and 30?)

ser[rPi].start(31, 30, 0, 9600)
repeat
    ser[rPi].dec(10)
    ser[rPi].tx(13)
    ser[rPi].tx(10)

The other end using Python seems to be a nightmare! :/

Comments

  • Hi,
    I have had a setup to control my little lathe with a combination of raspi and P1.
    In this setup I used Tachyon Forth on the P1 side for programming and also as protocol. This I consider to be a very good approach.

    Python on raspi.

    Last year though I realised that you can reserve cores of raspi, so I now control the steppers directly with GForth on the raspi. This setup is a good deal less complex and works well too.

    Christof

  • The other end needs to be something like this. Problem solved.

    #!/usr/bin/env python
    import serial
    ser = serial.Serial(port='/dev/ttyUSB0',baudrate = 9600)
    
    seq = []
    count = 1
    
    while True:
        for c in ser.read():
    
            seq.append(chr(c)) 
            joined_seq = ''.join(str(v) for v in seq) 
    
            if chr(c) == '\n':
                print("Line " + str(count) + ': ' + joined_seq)
                seq = []
                count += 1
                dat = joined_seq.split(",")
                print(dat[0])                     
                break
    
Sign In or Register to comment.