-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserial_comms_h.ads
More file actions
79 lines (63 loc) · 2.97 KB
/
serial_comms_h.ads
File metadata and controls
79 lines (63 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
package serial_comms_h is
function C_set_interface_attribs
(fd : int;
speed : unsigned;
databits : unsigned;
stopbits : unsigned;
parity : int;
flow : int;
local : int) return int; -- ./serial_comms.h:10
pragma Import (C, C_set_interface_attribs, "set_interface_attribs");
-- Set Blocking
-- should_block = 0 for non-blocking, VMIN time (i.e. minimum number of
-- characters to wait for) for blocking. For time-out, this is fixed at
-- 0.5 seconds.
-- int set_blocking (int fd, int should_block);
-- Alternative, maybe better, version, where mcount == should_block.
function C_set_mincount (fd : int; mcount : int) return int; -- ./serial_comms.h:18
pragma Import (C, C_set_mincount, "set_mincount");
-- The following sets both the blocking and time-out values
function C_set_blocking_and_timeout
(fd : int;
mcount : int;
timeout : int) return int; -- ./serial_comms.h:20
pragma Import (C, C_set_blocking_and_timeout, "set_blocking_and_timeout");
-- Open the file, where port name is defined as something like:
-- char *portname = "/dev/ttyUSB0";
function C_Open (fd : int; portname : Interfaces.C.Strings.chars_ptr) return int; -- ./serial_comms.h:24
pragma Import (C, C_Open, "Open");
-- And as read only
function C_Open_RO (fd : int; portname : Interfaces.C.Strings.chars_ptr) return int; -- ./serial_comms.h:24
pragma Import (C, C_Open_RO, "Open_RO");
-- tcgetattr gets the current terminal information and stores it in t.
-- If cmd is 1, the local input flag in t is set to non-blocking input.
-- Otherwise it is reset. Then tcsetattr changes standard input to t.
procedure C_stdin_set(cmd : int);
pragma Import (C, C_stdin_set , "stdin_set");
-- Close the file
function C_Close (fd : int) return int; -- ./serial_comms.h:27
pragma Import (C, C_Close, "Close");
-- Write the buffer, data out the device. len is the number of
-- valid characters in the buffer to write.
function C_Write
(fd : int;
data : Interfaces.C.Strings.chars_ptr;
len : int) return int; -- ./serial_comms.h:31
pragma Import (C, C_Write, "Write");
-- data is something like: unsigned char data[80];
-- returns the number of bytes read. If there is no data yet, then
-- 0 is returned.
function C_Read (fd : int; data : Interfaces.C.Strings.chars_ptr;
length : int) return int; -- ./serial_comms.h:36
pragma Import (C, C_Read, "Read");
-- Assuming the error has just occurred, turns the error number into
-- a string and returns it in 'data'.
procedure C_Errno_Message(err : int;
data : in out Interfaces.C.Strings.chars_ptr;
len : out int);
pragma Import (C, C_Errno_Message, "Errno_Message");
end serial_comms_h;