problem i am experiencing with Python "send" command.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dima81
    New Member
    • May 2010
    • 9

    problem i am experiencing with Python "send" command.

    I am having issues with the Python "send" command.
    For example, I am running the next code which is checking ADC.
    The code is right, there are no errors. I tried to run on other computer and it was fine.

    The script does a loop with the following operations:
    measures the ADC value at the ADC_IN1 pin, by issuing AT#ADC and AT#ADC=1,2,
    then using GPIO.getADC, then prints the result on the debug port, sleeps for
    0,5 sec
    (the permitted Vmax of the input is 2V)
    Code:
    import MDM
    import MOD
    import GPIO
    
    MDM.send("AT#ADC\r", 5)
    a = MDM.receive(20)
    print "AT#ADC:%s\r" % a
        
    print 'sleep 0,5 seconds\r'
    MOD.sleep(5)
    
    trial = 0
    while (1 == 1):
        trial = trial + 1
        print 'loop %d:\r' % trial
            
        MDM.send("AT#ADC=1,2\r", 5)
        a = MDM.receive(20)
        print "\tAT#ADC=1,2 --> %s\r" % a
    
        mv = GPIO.getADC(1)
        print "GPIO.getADC(1) --> %d mV\r" % mv
        
        print 'sleep 0,2 seconds\r'
        MOD.sleep(2)

    The error I get :

    Traceback (innermost last):
    File "C:\Program Files\Python\Py thonwin\pywin\f ramework\script utils.py", line 301, in RunScript
    exec codeObject in __main__.__dict __
    File "C:\Program Files\Python\Ex amples\ADC_test .py", line 39, in ?
    MDM.send("AT#AD C\r", 5)
    AttributeError: send

    I have to say that all of the codes that i tried to run with the "send" command, i always get this error!
    Last edited by Niheel; May 21 '10, 02:23 AM. Reason: punctuation, readability, code tags
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    This is not a Python error, but an MDM error. It appears that MDM does not have a function named "send". You will have to check the MDM documentation as I am not familiar with the software.

    Comment

    • dima81
      New Member
      • May 2010
      • 9

      #3
      Originally posted by dwblas
      This is not a Python error, but an MDM error. It appears that MDM does not have a function named "send". You will have to check the MDM documentation as I am not familiar with the software.
      Hey dwblas! Thanks for the fast response! There is no problem with MDM, because the same version of Python is running on friend's computer, and there it is just fine. I suspect my USB to RS232 converter is the problem, but on the other hand with Hyper Terminal it is works good.
      Last edited by Niheel; May 21 '10, 02:44 AM. Reason: Please use proper punctuation, spelling and grammar

      Comment

      • Glenton
        Recognized Expert Contributor
        • Nov 2008
        • 391

        #4
        I tend to use pyvisa for my RS232 control. But it depends what you're trying to do. And you'll need to install something like the NI visa drivers to get it to work. Are you running windows?

        I haven't used MDM, but is the 5 in the second parameter an address? Maybe the address is different on the two machines?

        Comment

        • dima81
          New Member
          • May 2010
          • 9

          #5
          ok... so as i was suspecting the problem was the converter from USB to RS232. i have connected the Computer to the terminal with the RS 232 cable abd it is run without any problem.
          tnx to all!

          Comment

          Working...