4 Replies - 38713 Views - Last Post: 19 February 2011 - 10:05 AM Rate Topic: -----

#1 totally_lost  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 13-September 06

bios.h and terminos.h in Dev c++ compiler

Posted 13 September 2006 - 11:52 PM

Hi everyone,

I am new here. I am using the C to do simple communciations to a serial port (like opening,reading, writing to the serial port.....). I use the Dev C++ compiler for this. But the first thing I encountered is that my code doesnt compile without some headers..
1. <termios.h>
2. <bios.h> (even though its not used in the below example)

Do you guys have any idea where to get them. I searched the whole net but wasnt smart enough to find a place I can downlaod these headers.

Or are there any better header files that can be used in place of these. I am totally lost at this point. Would greatly appreciate any help.


The code is below
	#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 */
	#incldue <conio.h>
	/*
	 * 'open_port()' - Open serial port 1.
	 *
	 * Returns the file descriptor on success or -1 on error.
	 */

	int
	open_port(void)
	{
	  int fd; /* File descriptor for the port */


	  fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | _NDELAY);
	  if (fd == -1)
	  {
	   /*
	* Could not open the port.
	*/

	perror("open_port: Unable to open /dev/ttyS0 - ");
	  }
	  else
	fcntl(fd, F_SETFL, 0);

	  return (fd);
	}

int main ()
{						open_port();
						  getch();
						  return 0;
}


This post has been edited by jayman9: 14 September 2006 - 07:53 AM


Is This A Good Question/Topic? 0
  • +

Replies To: bios.h and terminos.h in Dev c++ compiler

#2 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: bios.h and terminos.h in Dev c++ compiler

Posted 14 September 2006 - 07:20 AM

Here's the bios.h file
/*  bios.h

	Access to bios services.

*/

/*
 *	  C/C++ Run Time Library - Version 8.0
 *
 *	  Copyright (c) 1987, 1997 by Borland International
 *	  All Rights Reserved.
 *
 */
/* $Revision:   8.1  $ */

#if !defined(__BIOS_H)
#define __BIOS_H


#if !defined(___DEFS_H)
#include <_defs.h>
#endif


#if !defined(RC_INVOKED)

#if defined(__STDC__)
#pragma warn -nak
#endif

#endif  /* !RC_INVOKED */


#ifdef __cplusplus
extern "C" {
#endif


#if !defined(_Windows)

/* diskinfo_t structure for _bios_disk() */

struct diskinfo_t
{
	unsigned drive, head, track, sector, nsectors;
	void __far *buffer;
};

/* cmd values for _bios_disk() */

#define _DISK_RESET	 0   /* controller hard reset */
#define _DISK_STATUS	1   /* status of last operation */
#define _DISK_READ	  2   /* read sectors */
#define _DISK_WRITE	 3   /* write sectors */
#define _DISK_VERIFY	4   /* verify sectors */
#define _DISK_FORMAT	5   /* format track */

unsigned _RTLENTRY _bios_disk(unsigned __cmd, struct diskinfo_t _FAR *__dinfo);
int	  _RTLENTRY biosdisk(int __cmd, int __drive, int __head, int __track,
							int __sector, int __nsects, void _FAR *__buffer);
#endif  /* !_Windows */


#if !defined(_Windows) || defined(__DPMI16__) || defined(__DPMI32__)

/* cmd values for _bios_keybrd() */

#define _KEYBRD_READ			0	   /* read key */
#define _NKEYBRD_READ		   0x10	/* read key - enhanced */
#define _KEYBRD_READY		   1	   /* check key ready */
#define _NKEYBRD_READY		  0x11	/* check key ready - enhanced */
#define _KEYBRD_SHIFTSTATUS	 2	   /* get shift status */
#define _NKEYBRD_SHIFTSTATUS	0x12	/* get shift status - enhanced */

/* cmd values for _bios_printer() */

#define _PRINTER_WRITE  0	   /* send a byte to printer */
#define _PRINTER_INIT   1	   /* initialize printer */
#define _PRINTER_STATUS 2	   /* read printer status */

/* cmd values for _bios_serialcom() */

#define _COM_INIT	   0	   /* set communication parms to a byte */
#define _COM_SEND	   1	   /* send a byte to port */
#define _COM_RECEIVE	2	   /* read character from port */
#define _COM_STATUS	 3	   /* get status of port */

/* byte values for _COM_INIT cmd of _bios_serialcom() */

#define _COM_CHR7	   0x02	/* 7 data bits */
#define _COM_CHR8	   0x03	/* 8 data bits */
#define _COM_STOP1	  0x00	/* 1 stop bit */
#define _COM_STOP2	  0x04	/* 2 stop bits */
#define _COM_NOPARITY   0x00	/* no parity */
#define _COM_EVENPARITY 0x18	/* even parity */
#define _COM_ODDPARITY  0x08	/* odd parity */
#define _COM_110		0x00	/* 110 baud */
#define _COM_150		0x20	/* 150 baud */
#define _COM_300		0x40	/* 300 baud */
#define _COM_600		0x60	/* 600 baud */
#define _COM_1200	   0x80	/* 1200 baud */
#define _COM_2400	   0xa0	/* 2400 baud */
#define _COM_4800	   0xc0	/* 4800 baud */
#define _COM_9600	   0xe0	/* 9600 baud */

unsigned _RTLENTRY _bios_keybrd(unsigned __cmd);
unsigned _RTLENTRY _bios_printer(unsigned __cmd, unsigned __port, unsigned __abyte);
unsigned _RTLENTRY _bios_serialcom(unsigned __cmd, unsigned __port, unsigned __abyte);

int	  _RTLENTRY bioscom(int __cmd, char __abyte, int __port);
int	  _RTLENTRY bioskey(int __cmd);
int	  _RTLENTRY biosprint(int __cmd, int __abyte, int __port);

#endif  /* !_Windows || __DPMI16__ || __DPMI32__ */


#if !defined(__WIN32__) || defined(__DPMI32__)

/* cmd values for _bios_timeofday() */

#define _TIME_GETCLOCK  0   /* get clock count */
#define _TIME_SETCLOCK  1   /* set clock count */

/* Constants for biostime() */
#define _BIOS_CLOCKS_PER_SEC 18.2
#define _BIOS_CLK_TCK		_BIOS_CLOCKS_PER_SEC

/* register structure definitions for int86(), int86x() */

#ifndef _REG_DEFS
#define _REG_DEFS

struct WORDREGS
{
	unsigned int	ax, bx, cx, dx, si, di, cflag, flags;
};


struct BYTEREGS
{
	unsigned char   al, ah, bl, bh, cl, ch, dl, dh;
};

union  REGS
{
	struct  WORDREGS x;
	struct  BYTEREGS h;
};

struct  SREGS
{
	unsigned int	es;
	unsigned int	cs;
	unsigned int	ss;
	unsigned int	ds;
};

struct  REGPACK
{
	unsigned	r_ax, r_bx, r_cx, r_dx;
	unsigned	r_bp, r_si, r_di, r_ds, r_es, r_flags;
};

#endif /* _REG_DEFS */

unsigned _RTLENTRY _bios_equiplist(void);
unsigned _RTLENTRY _bios_memsize(void);
unsigned _RTLENTRY _bios_timeofday(unsigned __cmd, long _FAR *__timeval);

int	  _RTLENTRY biosequip(void);
int	  _RTLENTRY biosmemory(void);
long	 _RTLENTRY biostime(int __cmd, long __newtime);

int	  _RTLENTRY int86(int __intno,
						 union REGS _FAR *__inregs,
						 union REGS _FAR *__outregs );
int	  _RTLENTRY int86x(int __intno,
						  union  REGS  _FAR *__inregs,
						  union  REGS  _FAR *__outregs,
						  struct SREGS _FAR *__segregs );

#endif  /* !__WIN32__ || __DPMI32__ */


#ifdef __cplusplus
}
#endif


#if !defined(RC_INVOKED)

#if defined(__STDC__)
#pragma warn .nak
#endif

#endif  /* !RC_INVOKED */


#endif  /* __BIOS_H */


Copy and Paste the code.
But it's the Borland Version, so the functions may not work with Dev C++.

For the termios.h file, goto www.filesearching.com and search for it.
I found a number of them, all variants of each other.
Choose which one suits you best depending on the functions each one offers.
Was This Post Helpful? 1

#3 totally_lost  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 13-September 06

Re: bios.h and terminos.h in Dev c++ compiler

Posted 18 September 2006 - 12:43 AM

Thanks a million!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I ll try out my code including this libararies..........its really cool so see how u guys help each other out in this forum :)
Was This Post Helpful? 0
  • +
  • -

#4 Guest_Donie*


Reputation:

Re: bios.h and terminos.h in Dev c++ compiler

Posted 18 February 2011 - 11:47 PM

I have problem in bios.h header file when I compile it using Dev-c++.. The following are the errors:
20 C:\Dev-Cpp\include\BIOS.h variable or field `far' declared void
20 C:\Dev-Cpp\include\BIOS.h [Warning] no semicolon at end of struct or union
20 C:\Dev-Cpp\include\BIOS.h syntax error before '*' token

I'm trying to communicate to a microcontroller via PC serial.

When I compiled the same using TURBOC it compiled successfully but when I tried to run it I got the message stating as follows :
The system cannot open COM1 port requested by the application.
Was This Post Helpful? 0

#5 jimblumberg  Icon User is online

  • member icon


Reputation: 4017
  • View blog
  • Posts: 12,400
  • Joined: 25-December 09

Re: bios.h and terminos.h in Dev c++ compiler

Posted 19 February 2011 - 10:05 AM

First the bios.h header file is a header file for DOS and it is compiler specific. A Borland header file requires the Borland compilers.

Quote

I use the Dev C++ compiler for this.

Now these headers:

Quote

#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 */

are standard Unix/Linux headers. Are you trying to compile a Unix/Linux type program using MSYS?

Quote

When I compiled the same using TURBOC it compiled successfully but when I tried to run it I got the message stating as follows :
The system cannot open COM1 port requested by the application.

If you have changed your program since your first post please post the new code. Also what compiler are you using. If you switched to TURBO C I would suggest you go back to Dev C++. But


I would suggest that you check this boards FAQ for suggestions for a current standard compliant compiler. Maybe CodeBlocks or MinGW, or Visual C. Turbo C really should be allowed to Rest in Peace. This compiler is at least 30 years old and is non-standard (The standards are newer than this compiler) and obsolete. Depending on which version it may only produce 16 bit programs.


If you are using Windows then this new modern operating system has much better methods for serial port access than the old outdated buggy DOS Bios routines. You can check out this link: Window serial ports for one such resource.


Edit: Please don't resurrect old posts.

Jim

This post has been edited by jimblumberg: 19 February 2011 - 10:29 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1