Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Communicate on a serial port

e_grenon
Beginner
986 Views
Hello,
I have an Agilent 34401A multimeter and I try to build a program to communicate with it in compaq visual fortran 6.Themultimeter needs to communicate with the DTR / DSR handshaking, 9600baud, parity none, 1 start bit, 2 stop bits and 8 bits data.I havecommunicateto the multimeter with a shareware like hyper terminal. It works but I have to put an line feed character at the end of each command (ex: "SYST:REM"). I have done a little program in fortran with SPORT_xx but when I try to write a command on the Com1, my program nevercompletethe instruction SPORT_WRITE_DATA(...).Maybe I need to use the SPORT_SPECIAL_FUNCT but I dont find in the help the use of this function.
this is the main part of my little program:
...
iresult = SPORT_CONNECT(1,DL_OUT_LF)
iresult = SPORT_SET_STATE(1,9600,0,8,2)
iresult = SPORT_WRITE_DATA(1,'SYST:REM',0) (...and the program never complete this line when I run it...)
...
Thank you. It's the first time that I have to communicate with a com port and I am a newbie in programming.
Eric Grenon
0 Kudos
5 Replies
Steven_L_Intel1
Employee
986 Views
Read the documentation of SPORT_SET_STATE carefully. The arguments aren't what you think they are, especially regarding the stop bits.
0 Kudos
e_grenon
Beginner
986 Views

Thank you for your answer...

I read the documentation:

iresult =

SPORT_SET_STATE (port [, baud] [, parity] [, dbits] [, sbits])

sbits:

(Optional; input) Integer. The stop bits for the port (0, 1, 2 = 1, 1.5, 2).

I don't understand what that mean : "(0 , 1, 2 = 1, 1.5, 2)"

what should I write if I want 2 stop bits ???

Thanks,

Eric Grenon

0 Kudos
Steven_L_Intel1
Employee
986 Views
As it turns out, your call to SPORT_SET_STATE is fine. I've seen others run into trouble here. The values for the stop bits argument are: 0 means 1, 1 means 1.5, 2 means 2.

I don't know why your code doesn't work. Dealing with serial ports can be difficult. But I see that you don't check the result values - you should. They may tell you something.
0 Kudos
jparsly
New Contributor I
986 Views

I'm suspicious about the stop bits setting. Are you sure that it is supposed to

be 2? In olden days, the baud rate was always a multiple of

(start bit + parity bit + data bits + stop bits), and you had 110 baud =

10 characters per second, 300 baud = 30 characters per second, 1200

baud = 120 characters per second. 110 baud was the odd one, using

11 bits per characters because it had 2 stop bits.The data bits +

parity bit would always add up to 8 (i.e. 8 data bits, no parity or

7 data bits, odd parity). For 9600 baud, I think I would expect the

stop bits to be 1.

0 Kudos
e_grenon
Beginner
986 Views

I verified in the user manual of the multimeter and it's specified 2 stops bits:

I have an other question: should I do something to configure DTR / DSR ???

RS-232 Interface Configuration

The multimeter is configured as a DTE (Data Terminal Equipment) device. For all communications over

the

RS-232 interface, the multimeter uses two handshake lines: DTR (Data Terminal Ready) on pin 4 and DSR (Data Set Ready) on pin 6.

RS-232 Configuration Overview

Configure the

RS-232 interface using the parameters shown below.

Baud Rate: 300, 600, 1200, 2400, 4800, or 9600 baud (factory setting)

Parity and Data Bits: None / 8 data bits (factory setting)

Even / 7 data bits, or Odd / 7 data bits

Number of Start Bits: 1 bit (fixed)

Number of Stop Bits: 2 bits (fixed)

Thank you, Eric Grenon

0 Kudos
Reply