Can't use Serial.serial.read() on ubuntu 12.04 but it is working fine on ubuntu 10.04

I was using ubuntu 10.04 and now updating to ubuntu 12.04 but one of my python code was working fine in ubuntu 10.04 but not in ubuntu 12.04.(Ubuntu 10.04: python version = 2.6.5, Ubuntu 12.04: python version = 2.7.3)
Here is my code.

class FTSensor:
def init(self, dev, baudrate=19200):
print ‘FTSensor: opening serial port (baudrate =’, baudrate, ‘)’
self.ftcon = serial.Serial(dev,timeout =0.1)
print ‘FTSensor: setting properties’
self.ftcon.setBaudrate(baudrate)
self.ftcon.setParity(‘N’)
self.ftcon.setStopbits(1)
self.ftcon.open()

          #self.RESET_INTERVAL=1.0 #seconds until transmittion is reset to fix bug
          count = 0
          self.reset_time = None
          self.reset()
          while not self._start_query():
                    rospy.logwarn('FTSensor: resetting')
                    count = count + 1
                    self.reset()
                    if count == 10:
                              rospy.logfatal('FTSensor.__init__: Too many resets.  Try manually restarting FT sensors.')

                #self.last_access = time.time()
                self.last_value = ]

def read(self):
#rospy.logwarn(‘READ’)

         current_value = self.last_value

         #rospy.logwarn(current_value)

         #rospy.logwarn('READ-BEFORE while')
         while current_value == self.last_value:
                  #rospy.logwarn('READ-INSIDE while')
                  ****t = self.ftcon.read(19)****
                  leng = t[0]
                  print leng
                  rospy.logwarn(t) 
      #if we get an error message, restart
                  if len(t) < 1 or ord(t[0]) != 0 or len(t) < 10:
           rospy.logwarn('READ-WHILE-if')                
           #pass
                           #self.reset()
                           print 'exiting due to if len(t) < 1 or ord(t[0]) != 0 or len(t) < 10'
                           print 't is', t
           exit()
                           while not self._start_query():
                                    #self.reset()
                                    print 'exiting due to not self._start_query()'
                                    print 't is', t
                                    exit()
                           break
      else:
                       #rospy.logwarn('READ-WHILE-else') 
                           current_value = t
                           #current_value = binary_to_ft(t)

         self.last_value = current_value
         return current_value

I did not put the main function but the one I highlighted(t = self.ftcon.read(19))
was the problem. From ubuntu 10.04 it was fine but from ubuntu 12.04,
it gives strange values like “D R .cracked letter” The type of t is list
so it wouldnt give me a number but I have no idea where D and R came
from.

Somebody mentioned about loading the kernel module with 8250.nr_uarts=8 but I have no idea how to load them :frowning:
Is there any other proecedure I need to follow to check what I am doing wrong?

Thank you.
-Brian

I was wondering if this is not working due to the difference of baudrate. I checked baudrate with minicom and set it 19200 for every case. I don’t know if it helped :frowning:

> Is there any other proecedure I need to follow to check what I am doing
> wrong?

i would try posting to the Ubuntu forum and see what they have to say…

alternatively, you might want to mention why you are posting to the
openSUSE forum?? (i mean, i know there are a few here who run both
openSUSE and Ubuntu, but still i would expect the largest mass of
Ubuntu experts to be somewhere besides here…

of course, ymmv…


dd
http://tinyurl.com/DD-Caveat

On 2013-06-26 18:46, wlsgus728 wrote:
>
> I was using ubuntu 10.04 and now updating to ubuntu 12.04 but one of my
> python code was working fine in ubuntu 10.04 but not in ubuntu
> 12.04.(Ubuntu 10.04: python version = 2.6.5, Ubuntu 12.04: python
> version = 2.7.3)

Are you aware that this is an openSUSE forum, not an ubuntu one?


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

@op- ubuntu 12.X is not equal to openSUSE 12.X though both are flavours of GNU/Linux.
It would be wise to ask question related to Ubuntu in Ubuntu forums as people in these forums may not be using Ubuntu