www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Newbie : SERIAL PORT

reply "BUDI ARIEF GUSANDI" <budi online.ie> writes:
Hi All,

1. How to access serial port (RS232) in D ? any have sample code ;)
2. What is D editor that has autocomplete feature ?

Thanks.

Budi
-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Sep 16 2004
parent reply Arcane Jill <Arcane_member pathlink.com> writes:
In article <opsega6ipaukcpn4 telkomnetinstan>, BUDI ARIEF GUSANDI says...
Hi All,

1. How to access serial port (RS232) in D ?
How do you access the serial port in C? The anwser to these two questions is likely to be identical, save possibly for translating some include file code from C to D. Anything you can do in C, you can do in D. Arcane Jill
Sep 16 2004
parent reply Martin <Martin_member pathlink.com> writes:
In linux the serial port is one file, i think in /dev/ directory, you write it
and read it like a usual file.
I think /dev/ttyS0 is com1  /dev/ttyS1 is com2 ...
But I haven't ever done it, so don't blame me if crashes your computer or
something. Search google for "/dev/ttyS0" or "linux serial port programming" or
look at http://www.comptechdoc.org/os/linux/programming/c/linux_pgcserial.html

How it is done in windows, I don't know and have'nt been able to figure out yet.


In article <cie1hr$p01$1 digitaldaemon.com>, Arcane Jill says...
In article <opsega6ipaukcpn4 telkomnetinstan>, BUDI ARIEF GUSANDI says...
Hi All,

1. How to access serial port (RS232) in D ?
How do you access the serial port in C? The anwser to these two questions is likely to be identical, save possibly for translating some include file code from C to D. Anything you can do in C, you can do in D. Arcane Jill
Sep 17 2004
parent reply "BUDI ARIEF GUSANDI" <budi online.ie> writes:
I've checked the website, and found this

#include <termios.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/signal.h>
#include <sys/types.h>

What about the header above ? should i just change the #include to import  
? or need to copy what to where ?

Regards

On Fri, 17 Sep 2004 10:05:27 +0000 (UTC), Martin  
<Martin_member pathlink.com> wrote:

 In linux the serial port is one file, i think in /dev/ directory, you  
 write it
 and read it like a usual file.
 I think /dev/ttyS0 is com1  /dev/ttyS1 is com2 ...
 But I haven't ever done it, so don't blame me if crashes your computer or
 something. Search google for "/dev/ttyS0" or "linux serial port  
 programming" or
 look at  
 http://www.comptechdoc.org/os/linux/programming/c/linux_pgcserial.html

 How it is done in windows, I don't know and have'nt been able to figure  
 out yet.


 In article <cie1hr$p01$1 digitaldaemon.com>, Arcane Jill says...
 In article <opsega6ipaukcpn4 telkomnetinstan>, BUDI ARIEF GUSANDI  
 says...
 Hi All,

 1. How to access serial port (RS232) in D ?
How do you access the serial port in C? The anwser to these two questions is likely to be identical, save possibly for translating some include file code from C to D. Anything you can do in C, you can do in D. Arcane Jill
Sep 17 2004
parent Cloud9 Virtual <cloud9virtual yahoo.com> writes:
BUDI ARIEF GUSANDI wrote:
 I've checked the website, and found this
 
 #include <termios.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/signal.h>
 #include <sys/types.h>
 
 What about the header above ? should i just change the #include to 
 import  ? or need to copy what to where ?
 
From nowhere. (Some of) Those includes are part of the POSIX interface and as of yet that has not been translated to D (to my knowledge). However, you have two avenues, and they both start with the C code as Jill said. Do your serial programming in C (one .c file for simplicity), and: a) compile it in C and link the object file into your D executable (easiest) b) - figure out what macros and function prototypes you use exactly, and write a .d "import" file with just what you need from the C header files - translate the C serial code into D I suggest a) as it is less work and less error prone, and more portable.
Sep 17 2004