a1200   NEWS   APPS   DOCS   ABOUT
a1200
----
a1200
----
Autodocs
 Devices:
 serial.device
  AbortIO
  BeginIO
  CMD_CLEAR
  CMD_FLUSH
  CMD_READ
  CMD_RESET
  CMD_START
  CMD_STOP
  CMD_WRITE
  CloseDevice
  OpenDevice
  SDCMD_BREAK
  SDCMD_QUERY
  SDCMD_SETPARAMS
Include
GuruMeditation
Docs » Autodocs » serial.device » OpenDevice

NAME

       OpenDevice -- Request an opening of the serial device.

SYNOPSIS

       error = OpenDevice("serial.device", unit, ioRequest, flags)
D0 A0 D0 A1 D1
BYTE OpenDevice(STRPTR, ULONG, struct IOExtSer *, ULONG);

FUNCTION

       This is an exec call.  Exec will search for the serial.device, and
if found, will pass this call on to the device.
Unless the shared-access bit (bit 5 of io_SerFlags) is set,
exclusive use is granted and no other access to that unit is
allowed until the owner closes it. All the serial-specific fields
in the ioRequest are initialized to their most recent values (or
the Preferences default, for the first time open).
If support of 7-wire handshaking (i.e. RS232-C CTS/RTS protocol)
is required, use the serial.device/SDCMD_SETPARAMS command.
This feature should also be specified at inital OpenDevice() time.

INPUTS

       "serial.device" - pointer to literal string "serial.device"
unit - Must be zero, or a user setable unit number.
(This field is used by multiple port controllers)
Zero specifies the default serial port.
ioRequest - pointer to an ioRequest block of size io_ExtSerSize
to be initialized by the serial.device.
(see devices/serial.h for the definition)
NOTE use of io_SerFlags (see FUNCTION above)
IMPORTANT: The ioRequest block MUST be of size io_ExtSerSize,
and zeroed (with the exeptions as noted)!
flags - Must be zero for future compatibility

RESULT

       D0        - same as io_Error
io_Error - If the Open succeded, then io_Error will be null.
If the Open failed, then io_Error will be non-zero.
io_Device - A pointer to whatever device will handle the calls
for this unit. This pointer may be different depending
on what unit is requested.

BUGS

       If 7-wire handshaking is specified, a timeout "feature" is enabled.
If the device holds off the computer for more than about 30-60
seconds, the device will return the write request with the error
SerErr_TimerErr. Don't depend on this, however. If you want a timeou
t,
set up the timer.device and wait for either timer, or serial IO to
complete.
On open, the serial.device prior to 43.4 allocates the
misc.resource for the serial port. It does not return it
until the serial.device is expunged from memory. The device
should return it when no more openers exist. The bug has
been fixed starting with 43.4. This code can force a
specified device to try and expunge. Of course, if the
device is in use nothing will happen:
#include "exec/types.h"
#include "exec/execbase.h"
#include "proto/exec.h"
void FlushDevice(char *);
extern struct ExecBase *SysBase;
void main()
{
FlushDevice("serial.device"); /* or parallel.device */
}
/*
* Attempts to flush the named device out of memory.
* If it fails, no status is returned; examination of
* the problem will reveal that information has no
* valid use after the Permit().
*/
void FlushDevice(name)
char *name;
{
struct Device *result;
Forbid();
if( result=(struct Device *)FindName(&SysBase->DeviceList,name) )
RemDevice(result);
Permit();
}

SEE ALSO

serial.device/CloseDevice(), serial.device/SDCMD_SETPARAMS(), <devices/serial.h>

Comments

Name:
E-mail: Use this if you want a message if you get a response, will not be shown.
Comment:
Select correct short for:

Kefrens

ATX
ANA
KEF
FC

Comments:

$VER: d0.se 1.14 Copyright © 2011-2022 Tobias Geijersson support at d0 dot se