Does FORTRAN 95 Support Hardware Serial Ports and Configuration?

In summary: Neither your VB app nor the FORTRAN program utilizes extensive string processing or system calls for file or pipe ops. That shared memory could on the client side be accessed by a lightweight C-library linked with the Fortran executable.But your VB prog is a good starting point - VB supports COM, thus it'd be seamless to plugin a lightweight in-process (dll) COM component which simply exposes an interfaces to a shared memory chunk.Or you could simply use g95's built-in serial port support.
  • #1
jelanier
67
1
Does FORTRAN support use of hardware serial ports? I need to write and read to a COM port.
If so, can you configure the port as well? (ie baud rate , parity ,data bits, stop bits )

Thanks,

Jim
 
Technology news on Phys.org
  • #2
What operating system are you using?
 
  • #3
  • #4
Win7 64b
 
  • #5
So, you can't configure the port from G95?
 
  • #6
Fortran, like many other languages, offers the possibility to call functions of whatever libraries, e.g. system libraries for port access in your case; how that can be implemented has been shown in the thread gsal pointed you to. Of course, I cannot tell for sure without trying myself with g95 on your platform, but from that pov it should be theoretically possible to get suffcient port access from g95 code by the measures described there.

Theoretically.

Personally speaking I would not even think about using such a flavor of interfacing.

In doubt I would simply get myself a fancy little C or C++-library, e.g. Boost.Asio, add a lightweight C-interface callable from Fortran, link that with main program and carry on.

It could even be considered delegating the serial stuff completely to a C/C++ MPI 2 program and having Fortran spawning that and gathering the data via that MPI only.

The latter would be my approach.
 
  • #7
Solkar said:
Fortran, like many other languages, offers the possibility to call functions of whatever libraries, e.g. system libraries for port access in your case; how that can be implemented has been shown in the thread gsal pointed you to. Of course, I cannot tell for sure without trying myself with g95 on your platform, but from that pov it should be theoretically possible to get suffcient port access from g95 code by the measures described there.

Theoretically.

Personally speaking I would not even think about using such a flavor of interfacing.

In doubt I would simply get myself a fancy little C or C++-library, e.g. Boost.Asio, add a lightweight C-interface callable from Fortran, link that with main program and carry on.

It could even be considered delegating the serial stuff completely to a C/C++ MPI 2 program and having Fortran spawning that and gathering the data via that MPI only.

The latter would be my approach.

I am already doing that. I am using a VB6 program to configure the port, read(by event) and write data to the serial port and passing strings to the FORTRAN program for number crunching.

Thanks anyway,

Jim
 
  • #8
jelanier said:
I am already doing that.
No, you don't...

jelanier said:
I am using a VB6 program to configure the port, read(by event) and write data to the serial port and passing strings to the FORTRAN program for number crunching.
...because both architectures I mentioned neither utilize extensive string processing nor system calls for file or pipe ops but work memory-based with binary data. And for good reasons.

But your VB prog is a good starting point - VB supports COM, thus it'd be seamless to plugin a lightweight in-process (dll) COM component which simply exposes an interfaces to a shared memory chunk.

That shared memory could on the client side be accessed by a lightweight C-library linked with the Fortran executable.
 
  • #9
Solkar said:
But your VB prog is a good starting point -

.

No, I am done. This already works fine. I have written many COM, client and server programs with VB6. It does fine with this. What I wrote was basically a VB GUI and I/O for the FORTRAN program. The VB does the I/O and the FORTRAN does the number crunching.

My question was whether G95 supports the hardware to the point where I didn't need the VB app at all. In this case, there is no need to use C or anything else. My VB app works fine for this purpose.

Thanks,

Jim
 
  • #10
jelanier said:
I have written many COM, client and server programs with VB6.
That's fortunate, but besides the point.
The point is architecture.
 

FAQ: Does FORTRAN 95 Support Hardware Serial Ports and Configuration?

What is FORTRAN 95 (G95) Serial Port?

FORTRAN 95 (G95) Serial Port is a programming language that is commonly used in scientific and engineering applications. It is an extension of the FORTRAN 77 language and includes additional features such as modules, pointers, and recursion.

How do I open and close a serial port in FORTRAN 95 (G95)?

To open a serial port in FORTRAN 95 (G95), you will need to use the OPEN statement and specify the port name, baud rate, and other settings. To close the serial port, you can use the CLOSE statement.

Can I read and write to a serial port in FORTRAN 95 (G95)?

Yes, you can use the READ and WRITE statements in FORTRAN 95 (G95) to communicate with a serial port. You will need to specify the unit number of the serial port and the variable you want to read from or write to.

What are some common errors that can occur when using a serial port in FORTRAN 95 (G95)?

Some common errors when using a serial port in FORTRAN 95 (G95) include incorrect settings or parameters, failure to open or close the port, and data transmission errors. It is important to carefully check your code and troubleshoot any errors that may occur.

Are there any libraries or modules available for serial port communication in FORTRAN 95 (G95)?

Yes, there are several libraries and modules that can be used for serial port communication in FORTRAN 95 (G95), such as serialportf and serialio. These libraries provide additional functions and features that can make serial port communication easier and more efficient.

Similar threads

Replies
1
Views
1K
Replies
2
Views
2K
Replies
2
Views
1K
Replies
2
Views
1K
Replies
7
Views
3K
Replies
1
Views
2K
Replies
6
Views
3K
Replies
4
Views
2K
Replies
5
Views
3K
Back
Top