0

I am trying to run a python app which controls sevomotors. There is no handshaking, just a bit bang from pin 3 of the DB9 straight into a PIC.

There is nothing showing on the oscilloscope: it's just flatlining.
I do a dmesg grep | tty and get nothing at all showing.

I've done:
sudo setserial ttyS0 autoconfig
mknod -m 660 /dev/ttyS0 c 4 64 # base address 0x03f8
/sbin/MAKEDEV -v ttyS0
Still nothing shows up on a dmesg

Until I run gtkterm. At which point I can press keys to my hearts content and the scope shows me pretty square waves.
But as soon as I close gtkterm, I've lost ttyS0.

This app apparently works for other people, but that doesn't help me a lot.

I'm running Mint Katya 2.6.38-13 on a Dell Latitude D430, connected to a docking station with a COM1 serial DB9 connector attached, and the BIOS is happy with COM1 active (as proved by gtkterm)

The app is attached as a text file.

So how do I get the computer to permanently see ttyS0, or what would I change in the app so that it will work?
I have python-serial installed, just don't really know what else do.


Anyone got any ideas?

Thank you in anticipation..

Fitch.

Attachments
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
module documentation
servoset.py
this is a small sample of text
'''

import Tkinter as GTK
import codecs
import logging
import math
import os.path
import serial
import sys
import time
import tkFileDialog
import tkFont
import tkMessageBox
import types
sys.path.append('/home/alistair/JMRI/servoset/colours')
import colours as Colour

# sys.getfilesystemencoding() = UTF-8
# sys.argv = ['servoset.py', '-q', 'that', 'this']

# the current list of exceptions... for ease of spelling
#
#   BaseException
##   +-- SystemExit
##   +-- KeyboardInterrupt
##   +-- GeneratorExit
#    +-- Exception
##        +-- StopIteration
#         +-- StandardError
#         |    +-- BufferError
#         |    +-- ArithmeticError
##        |    |    +-- FloatingPointError
##        |    |    +-- OverflowError
##        |    |    +-- ZeroDivisionError
##        |    +-- AssertionError
##        |    +-- AttributeError
#         |    +-- EnvironmentError
##        |    |    +-- IOError
##        |    |    +-- OSError
##        |    |         +-- WindowsError (Windows)
##        |    |         +-- VMSError (VMS)
##        |    +-- EOFError
##        |    +-- ImportError
#         |    +-- LookupError
##        |    |    +-- IndexError
##        |    |    +-- KeyError
##        |    +-- MemoryError
##        |    +-- NameError
##        |    |    +-- UnboundLocalError
##        |    +-- ReferenceError
##        |    +-- RuntimeError
##        |    |    +-- NotImplementedError
##        |    +-- SyntaxError
#         |    |    +-- IndentationError
#         |    |         +-- TabError
##        |    +-- SystemError
##        |    +-- TypeError
#         |    +-- ValueError
##        |         +-- UnicodeError
##        |              +-- UnicodeDecodeError
##        |              +-- UnicodeEncodeError
##        |              +-- UnicodeTranslateError
#         +-- Warning
#              +-- DeprecationWarning
#              +-- PendingDeprecationWarning
#              +-- RuntimeWarning
#              +-- SyntaxWarning
#              +-- UserWarning
#              +-- FutureWarning
#              +-- ImportWarning
#              +-- UnicodeWarning
#              +-- BytesWarning


def init_todo():
  phrase[K.todo] = 'To Do List'
  tips['To Do List'] = (
       u'Development tasks:\n'
       u'  Save As file coming up when it should just save ? \n'
       u'  Symetric checkbox\n'
       u'  Handling of open comm port')
  
class K:
  '''class documentation
K
this is a small sample of test'''
  # lookup keys to internationalisation, help, widget and field index, etc
  # list of global names rather than the char strings directly
  # to ease consistency, tracing, etc
  about = 'about'
  add = 'add'
  arr = 'arr'
  bname = 'bname'
  board = 'board'
  bpick = 'bpick'
  btos = 'btos'
  cancel = 'cancel'
  cflag = 'cflag'
  ch = 'channel'
  cha = 'J2'
  chb = 'J3'
  chc = 'J4'
  chd = 'J5'
  cname = 'cname'
  coma = 'coma'
  cpick = 'cpick'
  date = 'date'
  dead = 'dead'
  default = 'default'
  demo = 'demo'
  dox = 'dox'
  exit = 'exit'
  file = 'file'
  fname = 'fname'
  help = 'help'
  helpitem = 'hitem'
  helppane = 'hpane'
  helptext = 'htext'
  introa = 'introa'
  live = 'live'
  logo = 'logo'
  lradius = 'lradius'
  lthrow = 'lthrow'
  mail = 'eMail'
  merg = 'MERG'
  mpick = 'mpick'
  name = 'name'
  new = 'new'
  nullm = 'nullm'
  nullq = 'nullq'
  nulls = 'nulls'
  ok = 'ok'
  open = 'open'
  ofile = 'ofile'
  pause = 'pause'
  pflag = 'pflag'
  platform = 'platform'
  popa = 'popa'
  popb = 'popb'
  popc = 'popc'
  portlist = 'portlist'
  posn = 'posn'
  ppick = 'ppick'
  rate = 'rate'
  readme = 'README'
  reset = 'reset'
  resume = 'resume'
  router = 'router'
  runtime = 'runtime'
  save = 'save'
  saveas = 'saveas'
  sfile = 'sfile'
  servo = 'servo'
  servolab = 'servolab'
  servopic = 'servopic'
  set = 'set'
  sname = 'sname'
  spick = 'spick'
  sradius = 'sradius'
  state = 'state'
  sthrow = 'sthrow'
  stob = 'stob'
  storage = 'library'
  store = 'store'
  todo = 'todo'
  tools = 'tools'
  track = 'track'
  vnum = 'Status'
  windoze = 'windoze'
# end class k

#
# global variables are defined here
# those that will be set during execution are initialised as 'None'
# but are included here for documentation and reference purposes
#

# special character
alpha = u'\u03B1'

# description of application
app = {K.name: 'MERG Servo Board Programmer', K.vnum: 'alpha' }

# description of author
author = {K.name: 'J F Hamilton', K.mail: 'john@hamilton.org.uk', K.merg: '3201' }

# special character
beta = u'\u03B2'

# servo board output channels
channels = (K.cha,K.chb,K.chc,K.chd)

# comment character for file storage
cmnt = '#'

# switch open and closed
cols = (K.dead,K.live)

# will -> instance of Commport
comm = None

# special character
copyright = u'\u00A9'

# special character
darr = u'\u2193'

#  will -> instance of gui
display = None 

# special character
dot = u'\u2022'

# apologies for Java heritage
false = False

# configuration file input/output
fileargs = 'sset.txt'

# help file out
filehelp = 'sset.html'

# readme file out
fileread = K.readme+'.TXT'

# will -> mono font of suitable size
fontmono = None

# will -> sans serif font 
fontsans = None

# field separator in file storage
fsep = '|'

#  will be Tk()
graphix = None 

# will be replaced by help text, partly from config file
helpabout = None

# special character
larr = u'\u2190'

# will -> error logger
log = None

# will be graphic for merg logo
merglogo = None

# just shorthand
nl = '\n'

# placeholder for missing keyword in tips file
nokey = '@'

# words loaded and potentially stuff for internationalisation
phrase = {} 

# special character
rarr = u'\u2192'

# special character
reg = u'\u00AE'

# configuration data for the servo board
# rows used by all firware versions
servrows = (K.posn,K.rate)
# rows used only by sema versions
semarows = (K.popa,K.popb,K.popc)
# all rows
rows = servrows + semarows

# PIC firware version
sema = 'SEMA4'

# PIC firware version
semb = 'SEMA4b'

# PIC firware version
serv = 'SRV4E'

# sipported firmware versions
modes = (serv,sema,semb)

#  will -> instance of Library
storage = None 

# help texts: some loaded from config file, some created during initialisation
tips = {} 

# special character
tmark = u'\u2122'

# apologies for Java heritage
true = True

# special character
uarr = u'\u2191'

# upper bounds for spin boxes
ubounds = {(serv,K.rate):8,(sema,K.rate):127,(semb,K.rate):127}

# window exit phrase, used to link exit action
windowexit = 'WM_DELETE_WINDOW'

xlate = (
#  internal         external    htnl
    ('\n '+dot+' ',  '<li>',   '<li>'),
    (rarr,           '->',     '&rarr;'),
    (larr,           '<-',     '&larr;'),
    ('\t',           '<t>',    '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'),
    (copyright,      '(C)',    '&copy;'),
    ('\n',           '<br>',   '<br>')
  )
  
# add file date... may be replaced by something more specific
try:
  w = time.localtime(os.path.getmtime(sys.argv[0]))
  app[K.date] = '%04d/%02d/%02d %02d:%02d:%02d' % (w.tm_year,w.tm_mon,w.tm_mday,w.tm_hour,w.tm_min,w.tm_sec)
except:
  app[K.date] = '2010/11/19'

def epilog(ofile):
  ofile.write(cmnt+' end of file')

def errmsg(number):
  err = 'E%03d' % number
  return err + ' ' + phrase[err]
# end errmsg

def fountain(show=False):
  fontlist = tkFont.families()
  if show:
    for item in sorted(fontlist):
      print item
  global fontsans
  for item in ('Lucida Sans','DejaVu Sans','Liberation Sans','FreeSans','Verdana','Trebuchet MS','Arial'):
    if item in fontlist:
      fontsans = item
      break
  global fontmono
  for item in('Andale Mono','Lucida Sans Typewriter','Liberation Mono','DejaVu Sans Mono','Courier New','FreeMono'):
    if item in fontlist:
      fontmono = item  
      break
  log.debug((fontsans,fontmono))
#end fountain

def init_phrases():
  
  phrase[K.about] = 'About'
  phrase[K.add] = 'Add board'
  phrase[K.arr] = 'All rights reserved'
  phrase[K.btos] = u'BoardScreen'
  phrase[K.cancel] = 'Cancel'
  phrase[K.ch] = 'Channel'  # used as i/o kyword
  phrase[K.cha] = 'Channel: J2'
  phrase[K.chb] = 'Channel: J3'
  phrase[K.chc] = 'Channel: J4'
  phrase[K.chd] = 'Channel: J5'
  phrase[K.default] = 'Not specified'
  phrase[K.demo] = 'Demonstration'  # ta default setting
  phrase[K.dox] = 'Documentation'
  phrase[K.exit] = 'Exit'
  phrase[K.file] = 'File'
  phrase[K.help] = 'Help'
  phrase[K.new] = 'New'
  phrase[K.nullm] = 'CAUTION\nthe application may not respond to input\nfor the time you specify'
  phrase[K.nullq] = 'Duration of test (seconds):'
  phrase[K.nulls] = 'Port test'
  phrase[K.ok] = 'OK'
  phrase[K.open] = 'Load'
  phrase[K.ofile] = 'Open parameter file'
  phrase[K.platform] = 'linux2' # todo build in
  w = sys.version_info
  phrase[K.runtime] = sys.subversion[0][1:] + ' ' + str(w[0])+'.'+str(w[1])+'.'+str(w[2])
  phrase[K.save] = 'Save'
  phrase[K.saveas] = 'Save as'
  phrase[K.sfile] = 'Save parameter file as'
  phrase[K.state] = 'Switch'
  phrase[K.stob] = u'BoardScreen'
  phrase[K.tools] = 'Tools'
  global helpabout
  helpabout = (
        (K.vnum,     app[K.vnum]+'  '+app[K.date]),
        ('',         phrase[K.runtime]),
        (copyright,  author[K.name]+' '+app[K.date][:4]+' '+phrase[K.arr]),
        (K.merg,     author[K.merg]),
        (K.mail,     author[K.mail]),
        (copyright, 'Board firmware: '+K.merg+' '+phrase[K.arr])
        )
 
def menulist(*kwds):
  oline = ''
  for kwd in kwds:
    oline = '%s:%s' % (oline,phrase.get(kwd,'?'))
  return oline[1:]
  
def init_tips():
  global book
  book = Snode(title=app[K.name]+': User Guide')
  chap = Snode(kwd=K.introa,title='Introduction',parent=book)
  Snode(kwd=K.introa,parent=chap,content=
      'This is an interactive program for setting configuration values '
      'in the MERG servo control boards programmed with SRV4E or SEMA4 firmware. '
      'It stores configuration values for servos and boards in a Library, '
      'allowing for easy adjustment of values if needed. '
      'Right click on the mouse will show help (here) for the control over which the mouse cursor is placed.\n'
      'Topics are in alpha
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Fitchie
0

Well, at least you know that the port does work. Sorry but I'm not a Python programmer, so I can't tell you if there is a problem with the code. In any case, you should NOT have needed to create the device node for /dev/ttyS0 - that should by default be auto-configured by the OS for the COM1 port on your system. Do make sure (again) that the COM ports are enabled in the BIOS.

FWIW, I've used a lot of serial ports with a lot of Linux systems, and never saw this sort of problem. :-(

0

Do make sure (again) that the COM ports are enabled in the BIOS.

No problem.
I can echo directly to the chip just by "echo blah blah > ttyS0", which means ttyS0 is now permanently seen, so the port works fine, just something amiss between Mint and Python.

Edited by Fitchie: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.