serielle Kommunikation

HUE

Well-Known Member
Hallo,

wie muss ich mein NetBSD 5.0.2 konfigurieren, damit die serielle Verbindung über zwei USB-RS232 Adapter und Nullmodemkabel funktioniert. Ich führe folgende Befehle als root aus:

# Zeichen senden
echo -n "m" >/dev/ttyU0

#Zeichen empfangen
cat /dev/ttyU1

Hat dazu jemand einen Tipp?

MfG

HUE
 
warum musst du ueberhaupt etwas konfigurieren?
installier dir doch aus den ports einfach mal minicom.

das wird dich schon einen schritt weiterbringen!
 
Hallo,

Dettus, Sie haben recht! Mit minicom ging es auch ohne Konfiguration.

Mein Problem ist aber folgendes:

Ich habe einen Microcontroller mit serieller Schnittstelle gebaut, und dazu ein Programm in TCL geschrieben, welches auch unter OpenBSD läuft, am seriellen Port /dev/cua00 sowie auch mit dem USB-RS232 Adapter /dev/ttyU0.

Jetzt musste ich nach NetBSD migrieren und bekomme das Programm an der USB- Schnittstelle nicht zum laufen. Da habe ich obiges Hardware- Setup ausprobiert und bekomme nur mit minicom ein sinnvolles Ergebnis.

Sinn meiner ganzen Sache ist einen Webserver mit den Daten des Microcontrollers zu füttern und ein paar Tabellen und Grafiken zu machen. Hat auch prima geklappt, bis ich auf NetBSD umgestiegen bin. Seit dem hat die serielle Verbindung nicht mehr funktioniert.

Geht denn nicht mein Beispiel ohne minicom?

MfG

HUE
 
dein programm sollte normalerweise gegen die gleiche termios-lib gelinkt sein.
und damit sind die "treiber" auch das gleiche, dein proggie sollte also portierbar sein.

vielleicht ist das device nur ein anderes?
ansonsten guck dir auch nochmal die /etc/ttys an. (wenn es das unter netbsd gibt)
guck mal nach ob vielleicht auf dem device schon ein login-prompt laeuft.

oh, und aus eigener erfahrung weiss ich dass usb-adapter manchmal etwas biestig sind. die muss man schon ab- und zu mal auf beiden seiten trennen und wieder neu reinstecken damit sie laufen.
 
Hallo,

dmesg:

uhub5 at uhub0 port 1: vendor 0x03eb Standard USB Hub, class 9/0, rev 1.10/3.00, addr 2
uplcom0 at uhub5 port 1
uplcom0: Prolific Technology Inc. USB-Serial Controller, rev 1.10/3.00, addr 3
ucom0 at uplcom0
uplcom1 at uhub5 port 2
uplcom1: Prolific Technology Inc. USB-Serial Controller, rev 1.10/3.00, addr 4
ucom1 at uplcom1

Einen Verweis in der Manpage von ucom liefert die Datei /dev/ttyU*.

Habe ich einen Eintrag in der Datei /etc/ttys zu machen, um generell serielle Geräte wie Mikrocontroller oder Messgeräte mit serieller Schnittstelle zu machen(GPS Mouse, Logic Analyser o. ä.).

MfG

HUE
 
poste mal deine ganze dmesg.

/etc/ttys legt fest wo sich alles login-terminals befinden.
steht da ein /dev/ttyU (oder eine andere serielle schnittstelle) drinne, dann aender die datei bitte so dass dort keine login-konsole liegt.
 
dmesg:

Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009
The NetBSD Foundation, Inc. All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.

NetBSD 5.0.2 (MYCONF_N450) #14: Sat Apr 10 16:30:44 CEST 2010
wolfram@november.winter.de:/usr/src/sys/arch/i386/compile/MYCONF_N450
total memory = 1014 MB
avail memory = 989 MB
timecounter: Timecounters tick every 10.000 msec
timecounter: Timecounter "i8254" frequency 1193182 Hz quality 100
ASUSTeK Computer INC. 1005P (x.x)
mainbus0 (root)
cpu0 at mainbus0 apid 0: Intel 686-class, 1666MHz, id 0x106ca
cpu1 at mainbus0 apid 1: Intel 686-class, 1666MHz, id 0x106ca
ioapic0 at mainbus0 apid 2: pa 0xfec00000, version 20, 24 pins
acpi0 at mainbus0: Intel ACPICA 20080321
acpi0: X/RSDT: OemId <_ASUS_,Notebook,12000915>, AslId <MSFT,00000097>
acpi0: failed to look up EC object \\_SB.PCI0.SBRG.EC0: AE_NOT_FOUND
acpi0: SCI interrupting at int 9
acpi0: fixed-feature power button present
timecounter: Timecounter "ACPI-Fast" frequency 3579545 Hz quality 1000
ACPI-Fast 24-bit timer
attimer1 at acpi0 (TMR, PNP0100): AT Timer
attimer1: io 0x40-0x43 irq 0
pckbc1 at acpi0 (PS2K, PNP0303): kbd port
pckbc1: io 0x60,0x64 irq 1
pckbc2 at acpi0 (PS2M, SYN0A13): aux port
pckbc2: irq 12
pcppi1 at acpi0 (SPKR, PNP0800)
pcppi1: io 0x61
sysbeep0 at pcppi1
npx1 at acpi0 (COPR, PNP0C04)
npx1: io 0xf0-0xff irq 13
npx1: reported by CPUID; using exception 16
acpiec0 at acpi0 (EC0, PNP0C09): ACPI Embedded Controller
acpiec0: io 0x62,0x66
hpet0 at acpi0 (HPET, PNP0103)
hpet0: mem 0xfed00000-0xfed003ff
timecounter: Timecounter "hpet0" frequency 14318179 Hz quality 2000
acpibat0 at acpi0 (BAT0, PNP0C0A-0): ACPI Battery (Control Method)
acpibat0: battery info: ASUS, LION, 1005P
acpiacad0 at acpi0 (AC0, ACPI0003): ACPI AC Adapter
asus0 at acpi0 (ATKD, ASUS010-16843008)
acpilid0 at acpi0 (LID, PNP0C0D): ACPI Lid Switch
acpibut0 at acpi0 (SLPB, PNP0C0E): ACPI Sleep Button
acpibut1 at acpi0 (PWRB, PNP0C0C-170): ACPI Power Button
acpitz0 at acpi0 (TZ00): critical 98.0C passive 35.0C, passive cooling
apm0 at acpi0: Power Management spec V1.2
pckbd0 at pckbc1 (kbd slot)
pckbc1: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard
pms0 at pckbc1 (aux slot)
pms0: Synaptics touchpad version 7.2
pms0: Palm detect
pckbc1: using irq 12 for aux slot
wsmouse0 at pms0 mux 0
attimer1: attached to pcppi1
pci0 at mainbus0 bus 0: configuration mode 1
pci0: i/o space, memory space enabled, rd/line, rd/mult, wr/inv ok
pchb0 at pci0 dev 0 function 0
pchb0: vendor 0x8086 product 0xa010 (rev. 0x00)
vga1 at pci0 dev 2 function 0: vendor 0x8086 product 0xa011 (rev. 0x00)
wsdisplay0 at vga1 kbdmux 1: console (80x25, vt100 emulation), using wskbd0
wsmux1: connecting to wsdisplay0
drm at vga1 not configured
vendor 0x8086 product 0xa012 (miscellaneous display) at pci0 dev 2 function 1 not configured
azalia0 at pci0 dev 27 function 0: Generic High Definition Audio Controller
azalia0: interrupting at ioapic0 pin 22
azalia0: host: 0x8086/0x27d8 (rev. 2), HDA rev. 1.0
ppb0 at pci0 dev 28 function 0: vendor 0x8086 product 0x27d0 (rev. 0x02)
pci1 at ppb0 bus 4
pci1: no spaces enabled!
ppb1 at pci0 dev 28 function 1: vendor 0x8086 product 0x27d2 (rev. 0x02)
pci2 at ppb1 bus 2
pci2: memory space enabled, rd/line, wr/inv ok
wpi0 at pci2 dev 0 function 0: vendor 0x8086 product 0x4222 (rev. 0x02)
wpi0: interrupting at ioapic0 pin 17
wpi0: MoW2, address 00:13:02:38:4c:f7
wpi0: 11a rates: 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
wpi0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
wpi0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
ppb2 at pci0 dev 28 function 3: vendor 0x8086 product 0x27d6 (rev. 0x02)
pci3 at ppb2 bus 1
pci3: i/o space, memory space enabled, rd/line, wr/inv ok
vendor 0x1969 product 0x1062 (ethernet network, revision 0xc0) at pci3 dev 0 function 0 not configured
uhci0 at pci0 dev 29 function 0: vendor 0x8086 product 0x27c8 (rev. 0x02)
uhci0: interrupting at ioapic0 pin 23
usb0 at uhci0: USB revision 1.0
uhci1 at pci0 dev 29 function 1: vendor 0x8086 product 0x27c9 (rev. 0x02)
uhci1: interrupting at ioapic0 pin 19
usb1 at uhci1: USB revision 1.0
uhci2 at pci0 dev 29 function 2: vendor 0x8086 product 0x27ca (rev. 0x02)
uhci2: interrupting at ioapic0 pin 18
usb2 at uhci2: USB revision 1.0
uhci3 at pci0 dev 29 function 3: vendor 0x8086 product 0x27cb (rev. 0x02)
uhci3: interrupting at ioapic0 pin 16
usb3 at uhci3: USB revision 1.0
ehci0 at pci0 dev 29 function 7: vendor 0x8086 product 0x27cc (rev. 0x02)
ehci0: interrupting at ioapic0 pin 23
ehci0: EHCI version 1.0
ehci0: companion controllers, 2 ports each: uhci0 uhci1 uhci2 uhci3
usb4 at ehci0: USB revision 2.0
ppb3 at pci0 dev 30 function 0: vendor 0x8086 product 0x2448 (rev. 0xe2)
pci4 at ppb3 bus 5
pci4: no spaces enabled!
pcib0 at pci0 dev 31 function 0
pcib0: vendor 0x8086 product 0x27bc (rev. 0x02)
ahcisata0 at pci0 dev 31 function 2: vendor 0x8086 product 0x27c1
ahcisata0: interrupting at ioapic0 pin 21
ahcisata0: AHCI revision 1.1, 4 ports, 32 command slots, features 0xc720e000
atabus0 at ahcisata0 channel 0
ichsmb0 at pci0 dev 31 function 3: vendor 0x8086 product 0x27da (rev. 0x02)
ichsmb0: interrupting at ioapic0 pin 21
iic0 at ichsmb0: I2C bus
isa0 at pcib0
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
acpiacad0: AC adapter online.
azalia0: codec[0]: Realtek ALC269 (rev. 0.4), HDA rev. 1.0
audio0 at azalia0: full duplex, independent
uhub0 at usb0: vendor 0x8086 UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
uhub1 at usb2: vendor 0x8086 UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1: 2 ports with 2 removable, self powered
uhub2 at usb4: vendor 0x8086 EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
uhub2: 8 ports with 8 removable, self powered
ahcisata0 port 0: device present, speed: 1.5Gb/s
uhub3 at usb1: vendor 0x8086 UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub3: 2 ports with 2 removable, self powered
uhub4 at usb3: vendor 0x8086 UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub4: 2 ports with 2 removable, self powered
wd0 at atabus0 drive 0: <ST9160301AS>
wd0: drive supports 16-sector PIO transfers, LBA48 addressing
wd0: 149 GB, 310101 cyl, 16 head, 63 sec, 512 bytes/sect x 312581808 sectors
wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 6 (Ultra/133)
wd0(ahcisata0:0:0): using PIO mode 4, DMA mode 2, Ultra-DMA mode 6 (Ultra/133) (using DMA)
umass0 at uhub2 port 2 configuration 1 interface 0
umass0: vendor 0x05e3 USB TO IDE, rev 2.00/0.33, addr 2
umass0: using SCSI over Bulk-Only
scsibus0 at umass0: 2 targets, 1 lun per target
cd0 at scsibus0 target 0 lun 0: <TEAC, CD-224E, 2.7B> cdrom removable
uhub5 at uhub0 port 1: vendor 0x03eb Standard USB Hub, class 9/0, rev 1.10/3.00, addr 2
uhub5: 4 ports with 4 removable, self powered
ugen0 at uhub2 port 6
ugen0: Image Processor USB2.0 UVC VGA WebCam, rev 2.00/9.17, addr 3
pad0: outputs: 44100Hz, 16-bit, stereo
audio1 at pad0: half duplex
boot device: wd0
root on wd0a dumps on wd0b
root file system type: ffs
uplcom0 at uhub5 port 2
uplcom0: Prolific Technology Inc. USB-Serial Controller, rev 1.10/3.00, addr 3
ucom0 at uplcom0
wsdisplay0: screen 1 added (80x25, vt100 emulation)
wsdisplay0: screen 2 added (80x25, vt100 emulation)
wsdisplay0: screen 3 added (80x25, vt100 emulation)
wsdisplay0: screen 4 added (80x25, vt100 emulation)
uplcom1 at uhub5 port 1
uplcom1: Prolific Technology Inc. USB-Serial Controller, rev 1.10/3.00, addr 4
ucom1 at uplcom1






/etc/ttys

#
# from: @(#)ttys 5.1 (Berkeley) 4/17/89
# $NetBSD: ttys,v 1.19 2008/10/07 10:00:01 abs Exp $
#
# name getty type status comments
#
console "/usr/libexec/getty Pc" vt100 on secure
constty "/usr/libexec/getty Pc" vt100 off secure
ttyE0 "/usr/libexec/getty Pc" vt220 off secure
ttyE1 "/usr/libexec/getty Pc" vt220 on secure
ttyE2 "/usr/libexec/getty Pc" vt220 on secure
ttyE3 "/usr/libexec/getty Pc" vt220 on secure
tty00 "/usr/libexec/getty std.9600" unknown off secure
tty01 "/usr/libexec/getty std.9600" unknown off secure
tty02 "/usr/libexec/getty std.9600" unknown off secure
tty03 "/usr/libexec/getty std.9600" unknown off secure
tty04 "/usr/libexec/getty std.9600" unknown off secure
tty05 "/usr/libexec/getty std.9600" unknown off secure
tty06 "/usr/libexec/getty std.9600" unknown off secure
tty07 "/usr/libexec/getty std.9600" unknown off secure


Hier steht nichts von ttyU0 und ttyU1 drin. Wie muss denn die Datei aussehen, damit eine serielle Kommunikation mit Mikrocontrollern oder ähnlichem funktioniert?

MfG

HUE
 
die muss bar jeder zeile mit einem seriellen device aussehen.

nochmal: funktioniert minicom auf deiner kiste?
wie hast du dort die uebertragungsparameter eingestellt?
stellst du die uebertragungsparameter auch bei deinem proggie ein?


sagt dir das hier etwas? http://de.wikipedia.org/wiki/RS-232
 
Hi,

minicom läuft ohne Probleme. Dazu habe ich zu jeder Schnittstelle (ttyU0, ttyU1) je ein minicom laufen. Die Parameter sind von minicom vorgegeben.

In meinem Programm habe ich Baudrate und Buffering, Blocking und 8,n,1 eingestellt, es hat ja auch schon unter OpenBSD 4.5 problemlos ca. ein Jahr TAG UND NACHT gelaufen. Nur der Wechsel auf NetBSD 5.0.2 ist nicht drin. Mir ist es ein Rätsel, warum minicom ohne großen Spuk läuft, und die Programme im Terminal nicht gehen. Siehe 1. Post.

MfG

HUE
 
oehm...
ich merke gerade... du schreibst nach /dev/ttyU0 und liest von U1? :eek:

ausserdem ist das beschreiben von den devices von der konsole aus kein besonders sauberer programmierstil. :belehren: ich hatte bis jetzt angenommen dass du dafuer ein c- oder perl-programm oder aehnliches hast.
wenn nicht, empfehle ich dir selbiges zu schreiben.

denn KEINE ahnung was die bash genau mit der seriellen schnittstelle macht: unter umstaenden gibt es noch eine schicht im kernel die erst einmal ein wenig buffert bevor sie die zeichen weitergibt.
oder die standard-uebertragungsparameter sind andere.
oder die terminal-emulation schickt jedes mal komische steuerzeichen mit.
oder...

fazit: schreib dir ein c-programm.
 
Hallo oh,

Ich habe ja ein Programm in der Sprache TCL geschrieben, welches plattformunabhängig läuft, die seriellen Schnittstellen muss man dann der Plattform anpassen (OpenBSD /dev/cuaU0, NetBSD /dev/ttyU0).

Es ist ja nicht so, das es nicht läuft, ich hatte es schon auf NetBSD vor 2 Jahren am laufen, geändert dann für OpenBSD, da lief es ohne Unterbrechung ca. 1 Jahr, und nun muß ich die Anzahl der seriellen Schnittstellen erweitern, und wollte über einen USB- Hub mehrere RS232 emulieren, mit entsprechenden Adapter natürlich.

Die Adapter werden als ucom0 und ucom1 erkannt, eine Kommunikation ist unter NetBSD weder über die Shell (s. oben) noch das TCL- Programm geht.

Ich denke ich habe eine falsche oder fehlende Einstellung in der Datei /etc/ttys. Aber die richtige kann ich nicht finden, habe schon seit einer Woche die Suchmaschinen bemüht.

Hat jemand noch eine Idee?

MfG

HUE
 
Back
Top