forked from ImortisInglorian/fbrtLib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdev_com_test.bas
55 lines (44 loc) · 1.22 KB
/
dev_com_test.bas
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
/' COMx device '/
#include "fb.bi"
extern "C"
function fb_DevComTestProtocolEx ( handle as FB_FILE ptr, filename as ubyte const ptr, filename_len as size_t, pPort as size_t ptr ) as long
dim as ubyte ptr ch
dim as size_t i, port
if ( pPort <> 0 ) then
*pPort = 0
end if
if ( strncasecmp(filename, "SER:", 4) = 0 ) then
if ( pPort ) then
*pPort = 1
end if
return TRUE
end if
if ( filename_len < 4 ) then
return FALSE
end if
if ( strncasecmp(filename, "COM", 3) <> 0 ) then
return strchr( filename, asc(":") ) <> NULL
end if
port = 0
i = 3
ch = @filename[i]
while( ch >= asc("0") and ch <= asc("9") )
port = port * 10 + (*ch - asc("0"))
ch = @filename[i + 1]
wend
/' removed to allow for open com "COM:"
if( port==0 )
return FALSE;
'/
if ( ch <> asc(":") ) then
return FALSE
end if
if ( pPort <> 0 ) then
*pPort = port
end if
return TRUE
end function
function fb_DevComTestProtocol ( handle as FB_FILE ptr, filename as ubyte const ptr, filename_len as size_t ) as long
return fb_DevComTestProtocolEx( handle, filename, filename_len, NULL )
end function
end extern