old_contents: #!/usr/bin/env python
  
  # This is a quick and dirty example of how to use the MoteIF interface in Python
  import os
  import sys
  import time
  import ChatMsg  # Automatically generated by the MIG.
  
  from tinyos.message import MoteIF
  
  MSG_LEN = 59  # Because there is null termination
  
  class Chat:
      def __init__(self, motestring):
          # Create a MoteIF
          self.mif = MoteIF.MoteIF()
          # Attach a source to it
          self.tos_source = self.mif.addSource(motestring)
          # SomeMessageClass.py would be generated by MIG
          self.mif.addListener(self, ChatMsg.ChatMsg)
  
      # Called by the MoteIF's receive thread when a new message
      # is received
      def receive(self, src, msg):
          print("Received message: {}".format(msg))
          print("Received message: {}".format("".join([chr(c) for c in msg])))
  
      def send(self, msg):
          print "Sending message: {}...".format(msg)
          smsg = ChatMsg.ChatMsg()
          smsg.setString_msg(msg)
          self.mif.sendMsg(
              self.tos_source, 0xFFFF, smsg.get_amType(), 0, smsg
          )
  
      def main_loop(self):
          while True:
              msg = raw_input("-->")
              if len(msg) <= MSG_LEN:
                  msg = msg + "\x00" * (MSG_LEN - len(msg))
                  assert len(msg) == MSG_LEN, len(msg)
                  self.send(msg)
              else:
                  print("Message too long, try again.")
  
  def main():
     if '-h' in sys.argv or len(sys.argv) < 2:
         print "Usage:", sys.argv[0], "sf@localhost:9002", "adc_rev_volt <Volt>"
         sys.exit()
  
     m = Chat(sys.argv[1])
     m.main_loop()  # don't expect this to return...
  
  if __name__ == "__main__":
      print "I'm running..."
      main()
  
new_contents: #!/usr/bin/env python
  
  # This is a quick and dirty example of how to use the MoteIF interface in Python
  import os
  import sys
  import time
  import ChatMsg  # Automatically generated by the MIG.
  
  from tinyos.message import MoteIF
  
  MSG_LEN = 59  # Because there is null termination
  
  class Chat:
      def __init__(self, motestring):
          # Create a MoteIF
          self.mif = MoteIF.MoteIF()
          # Attach a source to it
          self.tos_source = self.mif.addSource(motestring)
          # SomeMessageClass.py would be generated by MIG
          self.mif.addListener(self, ChatMsg.ChatMsg)
  
      # Called by the MoteIF's receive thread when a new message
      # is received
      def receive(self, src, msg):
          print("Received message: {}".format(msg.data))
  
      def send(self, msg):
          print "Sending message: {}...".format(msg)
          smsg = ChatMsg.ChatMsg()
          smsg.setString_msg(msg)
          self.mif.sendMsg(
              self.tos_source, 0xFFFF, smsg.get_amType(), 0, smsg
          )
  
      def main_loop(self):
          while True:
              msg = raw_input("-->")
              if len(msg) <= MSG_LEN:
                  msg = msg + "\x00" * (MSG_LEN - len(msg))
                  assert len(msg) == MSG_LEN, len(msg)
                  self.send(msg)
              else:
                  print("Message too long, try again.")
  
  def main():
     if '-h' in sys.argv or len(sys.argv) < 2:
         print "Usage:", sys.argv[0], "sf@localhost:9002", "adc_rev_volt <Volt>"
         sys.exit()
  
     m = Chat(sys.argv[1])
     m.main_loop()  # don't expect this to return...
  
  if __name__ == "__main__":
      print "I'm running..."
      main()
  
subject: Fix message printing