From: Bülent Erdemir (buler@kocbank.com.tr)
Date: Thu 22 Aug 2002 - 09:12:01 EEST
/dev/ttyS0 1 no'lu COM portun surucu adresi olmali. Linux icin bu =
surucuyu
kullanmadim ama genelde unix'lerde, eger tty adinda buyuk harf varsa o
surucu bir modem surucusu olarak calisiyor ve bagli olan cihaz =
tarafindan CD
sinyali (Carrier Detect) gonderilmeden haberlesmeye izin vermiyor. Yani
sizin elektronik board'unuzun CD'yi yakmasi lazim, ancak bundan sonra =
veri
gonderebilir ve alabilirsiniz.=20
Bu CD bagimliligindan kurtulmak istiyorsaniz /dev/ttys0'i (s kucuk =
harf)
kullanin. Kucuk harfli olan tty suruculer normal RS-232 hatti gibi
calisirlar. CD hattina aldirmazlar.=20
B=FClent Erdemir
-----Original Message-----
From: hasan [mailto:hasanyetisen@yahoo.com]=20
Sent: Wednesday, August 21, 2002 10:42 PM
To: linux-yazilim@linux.org.tr
Subject: [linux-yazilim] seri_port_programlama
merhabalar;
C ile seri porttan elektronik boarda iletiler
g=F6ndermek istiyorum.=20
Infoboardun Seri Haberlesme Standardi: RS 232-C,
asynchronous, simplex
Iletim h=FDz=FD : 2400 bps
=C7er=E7eve yap=FDs=FD : 1 start bit, 8 data bits, no parity,
2 stop bits
Konnekt=F6r tipi : DB-09 / female
Konnekt=F6r baðlantýsý : Pin:3----------
receive data
Pin:5---------- data ground
A=FEag=FDdaki kodda bir=E7ok deneme yapmama ragmen bir sonuc =
alamad=FDm. Dosyay=FD
a=E7arkenki parametrelerde ve settingslerinde emin degilim. Boardun =
kabul
ettigi mesaj format=FD ise attach ettigim dosyada mevcut.=20
Yard=FDmlar=FDn=FDz icin te=FEekk=FCrler...
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h> /* Standard input/output
definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function
definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control
definitions */
struct termios options,oldone;
int fd,n; /* File descriptor for the port */
int open_port(void)
{
fd =3D open("/dev/ttyS0", O_RDWR | O_NOCTTY |
O_NONBLOCK);
if (fd < 0)
{
perror("open_port: Unable to open /dev/ttyS0 - ");
}
else=20
fcntl(fd, F_SETFL, FASYNC);
return (fd);
}
int main()
{
open_port();
tcgetattr(fd, &oldone);
tcgetattr(fd, &options);
options.c_cflag &=3D ~CBAUD;
options.c_cflag &=3D ~CSIZE;
options.c_cflag &=3D ~CSTOPB;
options.c_cflag &=3D ~CLOCAL;
options.c_cflag &=3D ~HUPCL;
options.c_cflag |=3D (B2400 | CS8 | CSTOPB | CLOCAL |
HUPCL);
=20
tcflush(fd, 2);
tcsetattr(fd, TCSANOW, &options);
if (cfgetispeed(&options) !=3D B2400)
printf("input speed is not 2400 bps.\n");
n=3Dwrite(fd,=20
"02303030311747475252522020202020202020202020202020202020202004",
62);
tcdrain(fd);
tcsetattr(fd, TCSANOW, &oldone);
close(fd);
return(0);
}
__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com
-- Binary/unsupported file stripped by Ecartis --
-- Type: text/richtext
-- File: Infoboard_attributes.rtf
-- Desc: Infoboard_attributes.rtf