¿ªÔÆÌåÓý

Locked Re: Problem calling one script from another #scripting


 

Hi Bob

I have successfully modified my codes as you suggested however I need the receiving programme to include a serial connection to drive a stepper motor. If I comment out the serial code part as shown below all works well but if I include those lines it does not work.

?

Does JMRI not like serial code? If so how could I automatically send commands to the stepper motor. (The stepper motor driver is on a Pico with a USB connection to the RPi but I don¡¯t think the stepper motor is the problem just the serial connection to the Pico.)

?

The successful script for the initiating programme, testsend.py is:

?

import sys

xyz=100

print(xyz)

execfile(jmri.util.FileUtil.getExternalFilename("scripts:testreceive.py"))

#execfile("testreceive.py")

print("data transferred")

?

?

The successful script for the receiving programme, testreceive.py? is:

?

import sys

¡®¡¯¡¯

import serial

port = "/dev/ttyACM2"

baudrate = 115200

ser = serial.Serial(port,baudrate)

if ser.isOpen():

? ? print(ser.name + ' is open')

¡®¡¯¡¯

print (xyz+1)


Thanks
Toni

Join [email protected] to automatically receive all group messages.