Python Forum
Global accessing of parameter to class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global accessing of parameter to class
#1
I need to access the variable from main.py to global_rrt.py. I need to access the variable serial_rrt_read in global_rrt.py under the calss frame_101.
global_rrt.py
global serial_rrt,serial_rrt_read           #Read data from RS232 port of fast charger
global serial_length                        #Determine the length of serial read from fast charger


from main import*
print serial_rrt_read
class frame_101:
        frame_101_serial =  "1111111100000000"
        frame_101_start  =  frame_101_serial[0:8]
        frame_101_f_id   =  frame_101_serial[8:16] 
        frame_101_end    =  frame_101_serial[632:640]

frame_101_data = frame_101()
#print frame_101_data.frame_101_serial
main.py
import time                     #Deals with date and time
#import serial                   #Acess for Serial Port
import subprocess               #Allows us to spawn processes
import os                       #Provides a way of using operating system dependent functionality
import sys                      #Access variables used or maintained by the interpreter
from global_rrt import*         #Access Global Variables in Main File

#Start Reading Serial Port Data
#serial_rrt = serial.Serial('/dev/ttyACM1', 9600, timeout=1)

while 1:
    #serial_rrt_read = ser.readline()
    serial_rrt_read = "1111111100000000"
    #print serial_rrt_read
    serial_length = len(serial_rrt_read)
    #print serial_length
    if(serial_length == 16):
        frame_101_data = frame_101()
        print "Hi"
        print frame_101_data.frame_101_serial
  
     
Reply


Messages In This Thread
Global accessing of parameter to class - by Mahamutha - Aug-23-2017, 06:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [ERROR] ParamValidationError: Parameter validation failed: Invalid type for parameter gdbengo 3 11,653 Dec-26-2022, 08:48 AM
Last Post: ibreeden
  accessing value in dict_values class CompleteNewb 14 5,450 Mar-31-2022, 04:02 AM
Last Post: deanhystad
  read a parameter after updating it in another class MKS2020 3 2,331 Jul-25-2020, 08:27 AM
Last Post: MKS2020
  accessing local variable outside class priyanka08 3 2,264 Sep-24-2019, 10:00 AM
Last Post: buran
  Global variable does not seem to be global. Columbo 6 3,835 Jul-15-2019, 11:00 PM
Last Post: Columbo
  The derivate class dosn't behave like the base when i pass parameter to them drudox 4 3,275 Aug-05-2018, 06:42 PM
Last Post: drudox
  How to print a global dictionary class properly 3dimensions 2 3,300 Apr-18-2018, 05:45 PM
Last Post: nilamo
  [Python Class] save method output to global file/list Vijay 3 5,211 Dec-23-2017, 03:20 AM
Last Post: Vijay

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020