This page (revision-7) was last changed on 27-Feb-2008 13:39 by MarkusMonderkamp 

This page was created on 12-Feb-2008 10:41 by MarkusMonderkamp

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
7 27-Feb-2008 13:39 4 KB MarkusMonderkamp to previous Rückmeldung vom Mitsubishi-Roboter?
6 12-Feb-2008 12:26 4 KB Thomas Bayen to previous | to last Terminalprogramme, insbes. auch CuteCom
5 12-Feb-2008 11:17 3 KB PeterHormanns to previous | to last
4 12-Feb-2008 11:15 3 KB PeterHormanns to previous | to last
3 12-Feb-2008 11:15 3 KB PeterHormanns to previous | to last
2 12-Feb-2008 11:12 3 KB PeterHormanns to previous | to last Java COM
1 12-Feb-2008 10:41 2 KB MarkusMonderkamp to last Nicht nur Roboter werden seriell gesteuert

Page References

Incoming links Outgoing links

Version management

Difference between version and

! Programmierung der seriellen Schnittstelle

Angeregt durch die gestrigen ersten Gehversuche von Thomas mit Franz'
frisch erworbenen \\ Mitsubishi-Industrieroboter per
[Minicom|http://en.wikipedia.org/wiki/Minicom] zu kommunizieren,
fallen mir spontan zwei Möglichkeiten ein, \\automatisiert Kontakt mit dem Gerät aufzunehmen:

1.#>> __Java und [javax.com|http://javax.com/]__, siehe [Javakurs|http://hestia.hs-niederrhein.de/~gkorsch/javakurs/wn8/wn8.htm] der FHN Krefeld zum Thema serielle Schnittstelle \\ Dort wird auch [Hyperterminal|http://de.wikipedia.org/wiki/HyperTerminal] als minicomm-Alternative angesprochen
<<::Die offizielle Java-COM-Schnittstelle ist eine Erweiterung des JDK: [http://java.sun.com/products/javacomm/], leider gibt es von Sun keine Implementierung für Linux, daher verweist Sun auf: [http://www.geeksville.com/~kevinh/linuxcomm.html] und [http://java.sun.com/products/javacomm/reference/faqs/index.html]
<<
2
# __Python & pyserial: siehe [Sourceforge.net|http://sourceforge.net/project/showfiles.php?group_id=46487] für Linux und Co.

Short introduction, ebenfalls von [Sourceforge|http://pyserial.sourceforge.net/]

Open port 0 at "9600,8,N,1", no timeout

>>> import serial
>>> ser = serial.Serial(0)  #open first serial port
>>> print ser.portstr       #check which port was realy used
>>> ser.write("hello")      #write a string
>>> ser.close()             #close port

Open named port at "19200,8,N,1", 1s timeout

>>> ser = serial.Serial('/dev/ttyS1', 19200, timeout=1)
>>> x = ser.read()          #read one byte
>>> s = ser.read(10)        #read up to ten bytes (timeout)
>>> line = ser.readline()   #read a '\n' terminated line
>>> ser.close()

Open second port at "38400,8,E,1", non blocking HW handshaking

>>> ser = serial.Serial(1, 38400, timeout=0,
...                     parity=serial.PARITY_EVEN, rtscts=1)
>>> s = ser.read(100)       #read up to one hunded bytes
...                         #or as much is in the buffer

Get a Serial instance and configure/open it later

>>> ser = serial.Serial()
>>> ser.baudrate = 19200
>>> ser.port = 0
>>> ser Serial<id=0xa81c10, open=False>(port='COM1', baudrate=19200, bytesize=8, parity='N', stopbits=1, timeout=None, xonxoff=0, rtscts=0)
>>> ser.open()
>>> ser.isOpen()
True
>>> ser.close()
>>> ser.isOpen()
False

Be carefully when using "readline". Do specify a timeout when opening the serial port otherwise it could block forever if no newline character is received. Also note that "readlines" only works with a timeout. "readlines" depends on having a timeout and interprets that as EOF (end of file). It raises an exception if the port is not opened correctly.

Do also have a look at the example files in the examples directory in the source distribution or online in CVS repository .

__für Win32: Serial-Package__ von Roger Burnham, http://www.marshallsoft.com

>>> from Serial import Serial
>>> #create a 'configuration dictionary' with the port settings
>>> myconfig = Serial.PortDict()
>>> myconfig['port'] = Serial.COM4
>>> # create and open a port with these settings
>>> myport = Serial.Port(myconfig)
>>> myport.open()
>>> myport.send('ATI\015') #ask modem to identify itself
>>> print myport.read() #get back an y response

--MarkusMonderkamp, 12.02.2008