Re: Servos, Ardunios, and JMRI #arduino
From your original post:
This symptom is consistent with the use of the same name for what should be considered two variables.
In the text you supplied in your most recent post, it is apparent that the variables named below are overwritten by the most recently executed script file:
and perhaps others. Only the constant for baudrate is benign in this case.
With the possible exception of the class name, all of the other variable names are shared by all of the instances of the most recent definition of the Datatransfer class that are created in the lines:
which appear at the bottom of both script texts. In effect, these instances will each use the most recently set values for each of the above identified variable names.
If these are correct copies of your scripts, It is my understanding that these lines set up duplicate copies of Turnouts PT1 through PT6.
If my understanding of these lines is correct, either script would only connect with what JMRI labels as turnouts with systemName choices PT1 though PT6. Did you in fact receive state change information concerning either set of your yard turnouts but using the same JMRI systemNames?
The original structure of the class definition in TurnoutDataTransfer.py does not lend itself to easy modification to multiple input-output connections to separate Arduino devices.
My preference would be to define a more robust class with a separate groupings of instances for each Arduino. But without the hardware resources to test with at least three Arduino devices it is not prudent for me to make such an attempt. In no case would I recommend executing two script files that define copies of the same class, but that is moot here.
In your case, the quick and dirty method to simply modify all of the variable names, other than the baudrate, as you have already done for a few variables might prove to be sufficient. It would not be surprising if you chose this path.
It would be prudent to review the tutorial at https://docs.python.org/3/tutorial/classes.html and in particular the section 9.2 "Python Scopes and Namespaces."
If indeed your plan is to consider adding numerous other controls with more variations of the script, this process could easily get both tedious and difficult to maintain.
If you wish to respond off list and are willing to put up with perhaps many iterative attempts, I could provide some help.
By the way, if you had made a subfolder in https://groups.io/g/jmriusers/files/ProblemsBeingWorkedOn with a unique identifier referencing either this problem or your name, and supplied that link in your post, I believe you would have gotten more responses from a wider source of knowledge. Only by accident did I discover your pasted text marked as "Show quoted text" which usually means previous postings in the same thread.
Cliff in Baja SoCal