Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
Programmable RF Attenuator
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Programmable RF Attenuator
Commits
b6339620
Commit
b6339620
authored
Apr 27, 2023
by
Dimitris Lampridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw: cleanup old programs, unused variables, etc
parent
2cd2e784
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
10 additions
and
287 deletions
+10
-287
Makefile
software/Makefile
+0
-1
Makefile
software/lib/Makefile
+2
-9
Makefile.install
software/lib/Makefile.install
+1
-6
oattnusbtest
software/lib/oattnusbtest
+5
-4
serial_mod_oau.c
software/lib/serial_mod_oau.c
+0
-23
test.c
software/lib/test.c
+0
-33
usb-enum.c
software/lib/usb-enum.c
+2
-2
Makefile
software/test/Makefile
+0
-16
oasis-usb-att-test.c
software/test/oasis-usb-att-test.c
+0
-193
No files found.
software/Makefile
View file @
b6339620
all clean
:
make
-C
lib
$@
make
-C
test
$@
software/lib/Makefile
View file @
b6339620
...
...
@@ -7,7 +7,7 @@ GIT_VERSION = $(shell git describe --dirty --tags --long)
NAME
=
oattnusb
LIBNAME
=
lib
$(NAME)
all
:
lib
testprog serial_mod_oau
doc
all
:
lib doc
lib
:
$(LIBNAME).a $(LIBNAME).so
$(LIBNAME).a
:
$(OBJS)
...
...
@@ -20,15 +20,8 @@ $(OBJS): $(LIBNAME).h $(LIBNAME)-i.h usb-enum.h
doc
:
doxygen oattn.doxy
testprog
:
LDLIBS += -ludev
testprog
:
test.o $(LIBNAME).a
$(CC)
$(CFLAGS)
$^
-o
$@
$(LDLIBS)
$(LDFLAGS)
serial_mod_oau
:
LDFLAGS += -lusb-1.0
serial_mod_oau
:
eeprom.o serial_mod_oau.o
clean
:
rm
-f
*
.a
*
.o
*
.so
testprog usb-enum serial_mod_oau
rm
-f
*
.a
*
.o
*
.so
rm
-rf
html
-include
Makefile.install
software/lib/Makefile.install
View file @
b6339620
VERSION
=
$(
shell
git describe
--dirty
--tags
--long
)
OATTN_ROOT
=
/acc/local/L867/drv/
$(NAME)
DOCROOT
=
/nfs/cs-ccr-nfsop/nfs1/vol30/local/doc/html/private/coht/doxy/
$(NAME)
INSTALL_ROOT
=
$(OATTN_ROOT)
/
$(VERSION)
install
:
doc
install
:
$(LIBNAME).a $(LIBNAME).so $(NAME)test
install
:
$(LIBNAME).h usb-enum.h
install
:
mkdir
-p
$(INSTALL_ROOT)
/lib
mkdir
-p
$(INSTALL_ROOT)
/include
mkdir
-p
$(INSTALL_ROOT)
/bin
mkdir
-p
$(INSTALL_ROOT)
/doc
ln
-s
../pyenv
$(INSTALL_ROOT)
/pyenv
ln
-sf
.
$(INSTALL_ROOT)
/include/
$(NAME)
install
-m
0775
$(LIBNAME)
.a
$(LIBNAME)
.so
$(INSTALL_ROOT)
/lib
install
-m
0775
$(NAME)
test
serial_mod_oau
$(INSTALL_ROOT)
/bin
install
-m
0775
$(NAME)
test
$(INSTALL_ROOT)
/bin
install
-m
0775
$(LIBNAME)
.h usb-enum.h
$(INSTALL_ROOT)
/include
rsync
-rtq
html/
$(DOCROOT)
/
software/lib/oattnusbtest
View file @
b6339620
...
...
@@ -91,7 +91,6 @@ class OattnUsbTest(cmd.Cmd):
def
do_list
(
self
,
arg
):
"""list devices and their access methods."""
self
.
fill_devarray
()
for
i
,
dev
in
enumerate
(
self
.
devices
):
print
(
'{}:
\t
l:{}
\t
serial:{}
\t
busdev:{}/{}
\t
busport:{}'
.
format
(
i
,
dev
[
'lun'
],
dev
[
'serial'
],
dev
[
'busnum'
],
dev
[
'devnum'
],
...
...
@@ -193,7 +192,6 @@ class OattnUsbTest(cmd.Cmd):
raise
for
device
in
self
.
devices
:
if
(
bus
,
dev
)
==
(
int
(
device
[
'busnum'
]),
int
(
device
[
'devnum'
])):
print
(
'breaking'
)
break
else
:
print
(
'device bus:{} dev:{} not found'
.
format
(
bus
,
dev
))
...
...
@@ -206,8 +204,11 @@ class OattnUsbTest(cmd.Cmd):
print
(
'ok, giving up.'
)
return
self
.
api
.
oau_factory_program_eeprom
.
argtypes
=
[
c_int
,
c_int
,
c_char_p
]
self
.
api
.
oau_factory_program_eeprom
(
bus
,
dev
,
bytes
(
str
(
serial
),
'ascii'
))
print
(
'new serial recorded!'
)
ret
=
self
.
api
.
oau_factory_program_eeprom
(
bus
,
dev
,
bytes
(
str
(
serial
),
'ascii'
))
if
(
ret
!=
0
):
print
(
'EEPROM programming error detected'
)
else
:
print
(
'new serial recorded!'
)
print
(
'quitting, please restart the test program'
)
return
True
...
...
software/lib/serial_mod_oau.c
deleted
100644 → 0
View file @
2cd2e784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern
int
(
*
oau_factory_program_eeprom
)(
unsigned
int
bus
,
unsigned
int
dev
,
char
*
serial
);
int
main
(
int
argc
,
char
*
argv
[])
{
int
ret
;
unsigned
int
bus
,
dev
;
char
serial
[
3
]
=
{
'F'
,
'F'
,
0
};
if
(
argc
!=
4
)
{
fprintf
(
stderr
,
"usage: %s bus dev serialno
\n
"
,
argv
[
0
]);
exit
(
1
);
}
bus
=
strtol
(
argv
[
1
],
NULL
,
0
);
dev
=
strtol
(
argv
[
2
],
NULL
,
0
);
strncpy
(
serial
,
argv
[
3
],
sizeof
(
serial
));
ret
=
oau_factory_program_eeprom
(
bus
,
dev
,
serial
);
return
ret
;
}
software/lib/test.c
deleted
100644 → 0
View file @
2cd2e784
#include <stdio.h>
#include <unistd.h>
#include "liboattnusb.h"
int
main
()
{
int
fd
=
oattnusb_open
(
0
);
for
(;;)
{
fprintf
(
stderr
,
"."
);
oattnusb_set_relay
(
fd
,
4
,
ATT_MINUS_20dB
);
sleep
(
1
);
fprintf
(
stderr
,
"."
);
oattnusb_set_relay
(
fd
,
4
,
ATT_ZERO_dB
);
sleep
(
1
);
fprintf
(
stderr
,
"."
);
oattnusb_set_relay
(
fd
,
4
,
ATT_MINUS_40dB
);
sleep
(
1
);
}
oattnusb_close
(
fd
);
return
0
;
}
software/lib/usb-enum.c
View file @
b6339620
...
...
@@ -27,7 +27,7 @@ struct oattnusb_devarray *oattnusb_get_devarray(unsigned int vendor_id, unsigned
{
struct
udev
*
udev
=
udev_new
();
struct
udev_enumerate
*
enumerate
=
udev_enumerate_new
(
udev
);
struct
udev_list_entry
*
devs
,
*
ptr
,
*
ptr2
;
struct
udev_list_entry
*
devs
,
*
ptr
;
int
found_devs
=
0
;
char
vid
[
6
],
did
[
6
];
...
...
@@ -36,7 +36,7 @@ struct oattnusb_devarray *oattnusb_get_devarray(unsigned int vendor_id, unsigned
udev_enumerate_add_match_property
(
enumerate
,
"ID_VENDOR_ID"
,
vid
);
udev_enumerate_add_match_property
(
enumerate
,
"ID_MODEL_ID"
,
did
);
udev_enumerate_scan_devices
(
enumerate
);
devs
=
udev_enumerate_get_list_entry
(
enumerate
);
udev_list_entry_foreach
(
ptr
,
devs
)
{
if
(
found_devs
>=
MAX_OUA
)
...
...
software/test/Makefile
deleted
100644 → 0
View file @
2cd2e784
-include
../lib/Makefile.ftdi
OBJS
=
oasis-usb-att-test.o
GIT_VERSION
=
$(
shell
git describe
--dirty
--tags
--all
--long
)
CFLAGS
+=
-I
../lib
-DGIT_VERSION
=
\"
$(GIT_VERSION)
\"
LDFLAGS
+=
-L
../lib
LDLIBS
+=
-loasis-usb-att
all
:
testprog
testprog
:
$(OBJS)
gcc
-o
oasis-usb-att-test
$(OBJS)
$(LDFLAGS)
$(LDLIBS)
clean
:
rm
-f
*
.o oasis-usb-att-test
software/test/oasis-usb-att-test.c
deleted
100644 → 0
View file @
2cd2e784
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <math.h>
#include <stdlib.h>
#include "liboasis-usb-att.h"
static
char
git_version
[]
=
"git_version: "
GIT_VERSION
;
int
device
;
int
selected_channel
;
int
relay_register
;
int
num_channels
;
char
relay_bit_string
[
20
];
void
uint16_to_bit_string
(
char
*
s
,
uint16_t
r
)
{
uint16_t
bitmask
;
int
i
;
bitmask
=
(
1
<<
15
);
for
(
i
=
0
;
i
<
19
;
i
++
)
{
s
[
i
]
=
' '
;
if
(
i
%
5
==
4
)
continue
;
s
[
i
]
=
r
&
bitmask
?
'1'
:
'0'
;
bitmask
>>=
1
;
}
s
[
i
]
=
0
;
}
int
get_dB_at_channel
(
int
chan
)
{
int
chan_db
;
chan_db
=
3
<<
((
chan
-
1
)
*
4
);
chan_db
=
(
chan_db
&
relay_register
)
>>
((
chan
-
1
)
*
4
);
if
(
chan_db
==
1
)
chan_db
=
20
;
else
if
(
chan_db
==
3
)
chan_db
=
40
;
return
chan_db
;
}
void
print_menu
()
{
int
i
;
uint16_to_bit_string
(
relay_bit_string
,
relay_register
);
// printf("\033[2J"); /* clear the screen */
// printf("\033[H"); /* position cursor at top-left corner */
printf
(
"
\n
--------------------------------------
\n
"
);
printf
(
"| OASIS USB Attenuator |
\n
"
);
printf
(
"| Test program |
\n
"
);
printf
(
"--------------------------------------
\n
"
);
printf
(
"
\n
----> Selected channel is %d
\n
"
,
selected_channel
);
printf
(
"
\n
----> Relays command register: %08x = [%s]
\n
"
,
relay_register
,
relay_bit_string
);
for
(
i
=
1
;
i
<=
num_channels
;
i
++
)
{
printf
(
"
\n\t
Channel %d: %2d dB "
,
i
,
get_dB_at_channel
(
i
));
if
(
i
==
selected_channel
)
printf
(
"[*]"
);
}
printf
(
"
\n\n
[0] - Re-read attenuation values
\n
"
);
printf
(
"
\n
[1] - Change current channel
\n
"
);
printf
(
"
\n
[2] - Set attenuation to 20dB
\n
"
);
printf
(
"
\n
[3] - Set attenuation to 40dB
\n
"
);
printf
(
"
\n
[4] - Unset attenuation
\n
"
);
printf
(
"
\n
[q] - Quit test
\n
"
);
printf
(
"
\n
Choose an option: "
);
}
int
get_register_value
(
int
fd
)
{
int
value
=
0
;
int
tmp
;
int
i
;
for
(
i
=
1
;
i
<=
num_channels
;
i
++
)
{
tmp
=
oau_att_get_relay
(
fd
,
i
);
tmp
=
tmp
<<
4
*
(
i
-
1
);
value
|=
tmp
;
}
return
value
;
}
void
change_channel
()
{
char
option
;
char
ch
;
/* Manual flush ?? */
while
(
(
ch
=
fgetc
(
stdin
))
!=
EOF
&&
ch
!=
'\n'
){}
printf
(
"
\n
Enter new channel [1-4]: "
);
scanf
(
"%c"
,
&
option
);
if
((
option
>=
'1'
)
&&
(
option
<=
'4'
))
{
selected_channel
=
atoi
(
&
option
);
}
else
{
printf
(
"Invalid channel
\n
"
);
}
}
static
void
print_version
(
char
*
pname
)
{
printf
(
"%s %s
\n
"
,
pname
,
git_version
);
printf
(
"%s
\n
"
,
liboau_att_version_s
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
fd
;
char
option
;
selected_channel
=
1
;
if
(
argc
!=
2
)
{
printf
(
"Insufficient number of arguments
\n
"
);
printf
(
"
\n
Please use: %s <lun_of_the_device>
\n
"
,
argv
[
0
]);
printf
(
"or: %s -v for version info
\n
"
,
argv
[
0
]);
exit
(
-
1
);
}
if
(
!
strcmp
(
"-v"
,
argv
[
1
]))
{
print_version
(
argv
[
0
]);
exit
(
0
);
}
else
{
device
=
atoi
(
argv
[
1
]);
}
if
((
fd
=
oau_att_open
(
device
))
<
0
)
{
perror
(
"open failed
\n
"
);
return
-
1
;
}
/* Check for channel count*/
num_channels
=
oau_att_get_nchannels
(
fd
);
if
(
num_channels
<
0
)
{
printf
(
"Can not get channel count. Exiting...
\n
"
);
return
-
1
;
}
do
{
relay_register
=
get_register_value
(
fd
);
print_menu
();
scanf
(
"%c"
,
&
option
);
switch
(
option
)
{
case
'0'
:
break
;
case
'1'
:
change_channel
();
break
;
case
'2'
:
oau_att_set_relay
(
fd
,
selected_channel
,
ATT_1
);
break
;
case
'3'
:
oau_att_set_relay
(
fd
,
selected_channel
,
ATT_2
);
break
;
case
'4'
:
oau_att_set_relay
(
fd
,
selected_channel
,
ATT_NONE
);
break
;
default:
if
((
option
!=
'q'
)
&&
(
option
!=
'Q'
))
printf
(
"Unknown option
\n
"
);
break
;
}
}
while
((
option
!=
'q'
)
&&
(
option
!=
'Q'
));
/* That's all folks! */
oau_att_close
(
fd
);
return
1
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment