From 374a639835518b3f2111b4487bcaa39f67fd48f6 Mon Sep 17 00:00:00 2001 From: ryanpdx Date: Sat, 15 Apr 2023 18:26:35 -0700 Subject: [PATCH] update for olaf v2 --- oresat_gps/__init__.py | 2 +- oresat_gps/__main__.py | 23 ++- oresat_gps/data/oresat_gps.dcf | 300 +++++++++++++++--------------- oresat_gps/data/oresat_gps.eds | 296 +++++++++++++++-------------- oresat_gps/gpio.py | 60 ------ oresat_gps/gps_resource.py | 67 +++---- oresat_gps/templates/skytraq.html | 177 +++++++++--------- requirements.txt | 4 +- setup.cfg | 2 +- 9 files changed, 450 insertions(+), 481 deletions(-) delete mode 100644 oresat_gps/gpio.py diff --git a/oresat_gps/__init__.py b/oresat_gps/__init__.py index 1a72d32..58d478a 100644 --- a/oresat_gps/__init__.py +++ b/oresat_gps/__init__.py @@ -1 +1 @@ -__version__ = '1.1.0' +__version__ = '1.2.0' diff --git a/oresat_gps/__main__.py b/oresat_gps/__main__.py index 3bd030d..cb9dd9f 100644 --- a/oresat_gps/__main__.py +++ b/oresat_gps/__main__.py @@ -1,23 +1,28 @@ import os -from flask import Blueprint, render_template -from olaf import app, rest_api, olaf_run +from olaf import app, rest_api, olaf_setup, olaf_run, render_olaf_template from .gps_resource import GPSResource -gps_bp = Blueprint('gps_template', __name__, template_folder='templates') - -@gps_bp.route('/skytraq') +@rest_api.app.route('/skytraq') def skytraq_template(): - return render_template('skytraq.html', title=os.uname()[1], name='SkyTraq') + return render_olaf_template('skytraq.html', name='SkyTraq') def main(): - app.add_resource(GPSResource) - rest_api.add_blueprint(gps_bp) - olaf_run(f'{os.path.dirname(os.path.abspath(__file__))}/data/oresat_gps.dcf') + path = os.path.dirname(os.path.abspath(__file__)) + + args = olaf_setup(f'{path}/data/oresat_gps.dcf') + mock_args = [i.lower() for i in args.mock_hw] + mock_skytraq = 'skytraq' in mock_args or 'all' in mock_args + + app.add_resource(GPSResource(mock_skytraq)) + + rest_api.add_template(f'{path}/templates/skytraq.html') + + olaf_run() if __name__ == '__main__': diff --git a/oresat_gps/data/oresat_gps.dcf b/oresat_gps/data/oresat_gps.dcf index 94f3106..e46571e 100644 --- a/oresat_gps/data/oresat_gps.dcf +++ b/oresat_gps/data/oresat_gps.dcf @@ -2,7 +2,7 @@ FileName=oresat_gps.dcf FileVersion=1 FileRevision=1 -LastEDS= +LastEDS=oresat_gps.eds EDSVersion=4.0 Description=OreSat GPS CreationTime=10:31PM @@ -37,7 +37,7 @@ NrOfTXPDO=16 LSS_Supported=0 [DeviceComissioning] -NodeID=52 +NodeID=0x34 NodeName=GPS BaudRate=1000 NetNumber=0 @@ -120,7 +120,7 @@ AccessType=ro DefaultValue=0x00000000 [OptionalObjects] -SupportedObjects=85 +SupportedObjects=87 1=0x1002 2=0x1003 3=0x1005 @@ -136,76 +136,78 @@ SupportedObjects=85 13=0x1016 14=0x1017 15=0x1019 -16=0x1023 -17=0x1029 -18=0x1200 -19=0x1400 -20=0x1401 -21=0x1402 -22=0x1403 -23=0x1404 -24=0x1405 -25=0x1406 -26=0x1407 -27=0x1408 -28=0x1409 -29=0x140A -30=0x140B -31=0x140C -32=0x140D -33=0x140E -34=0x140F -35=0x1600 -36=0x1601 -37=0x1602 -38=0x1603 -39=0x1604 -40=0x1605 -41=0x1606 -42=0x1607 -43=0x1608 -44=0x1609 -45=0x160A -46=0x160B -47=0x160C -48=0x160D -49=0x160E -50=0x160F -51=0x1800 -52=0x1801 -53=0x1802 -54=0x1803 -55=0x1804 -56=0x1805 -57=0x1806 -58=0x1807 -59=0x1808 -60=0x1809 -61=0x180A -62=0x180B -63=0x180C -64=0x180D -65=0x180E -66=0x180F -67=0x1A00 -68=0x1A01 -69=0x1A02 -70=0x1A03 -71=0x1A04 -72=0x1A05 -73=0x1A06 -74=0x1A07 -75=0x1A08 -76=0x1A09 -77=0x1A0A -78=0x1A0B -79=0x1A0C -80=0x1A0D -81=0x1A0E -82=0x1A0F -83=0x1F80 -84=0x6000 -85=0x6001 +16=0x1021 +17=0x1022 +18=0x1023 +19=0x1029 +20=0x1200 +21=0x1400 +22=0x1401 +23=0x1402 +24=0x1403 +25=0x1404 +26=0x1405 +27=0x1406 +28=0x1407 +29=0x1408 +30=0x1409 +31=0x140A +32=0x140B +33=0x140C +34=0x140D +35=0x140E +36=0x140F +37=0x1600 +38=0x1601 +39=0x1602 +40=0x1603 +41=0x1604 +42=0x1605 +43=0x1606 +44=0x1607 +45=0x1608 +46=0x1609 +47=0x160A +48=0x160B +49=0x160C +50=0x160D +51=0x160E +52=0x160F +53=0x1800 +54=0x1801 +55=0x1802 +56=0x1803 +57=0x1804 +58=0x1805 +59=0x1806 +60=0x1807 +61=0x1808 +62=0x1809 +63=0x180A +64=0x180B +65=0x180C +66=0x180D +67=0x180E +68=0x180F +69=0x1A00 +70=0x1A01 +71=0x1A02 +72=0x1A03 +73=0x1A04 +74=0x1A05 +75=0x1A06 +76=0x1A07 +77=0x1A08 +78=0x1A09 +79=0x1A0A +80=0x1A0B +81=0x1A0C +82=0x1A0D +83=0x1A0E +84=0x1A0F +85=0x1F80 +86=0x6000 +87=0x6001 [1002] ParameterName=Manufacturer status register @@ -501,6 +503,22 @@ DataType=0x0005 AccessType=rw DefaultValue=0 +;A master node can read this for a copy of the node's EDS file +[1021] +ParameterName=Store EDS +ObjectType=0x07 +DataType=0x000F +AccessType=ro +DefaultValue=0 + +;Indicate the format of the Store EDS +[1022] +ParameterName=Store format +ObjectType=0x07 +DataType=0x0005 +AccessType=ro +DefaultValue=0 + [1023] ParameterName=OS command ObjectType=0x09 @@ -518,18 +536,21 @@ ParameterName=Command ObjectType=0x07 DataType=0x000F AccessType=rw +DefaultValue=0 [1023sub2] ParameterName=Status ObjectType=0x07 DataType=0x0005 AccessType=ro +DefaultValue=0 [1023sub3] ParameterName=Reply ObjectType=0x07 DataType=0x000F AccessType=ro +DefaultValue=0 [1029] ParameterName=Error behavior @@ -602,7 +623,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1400sub1] ParameterName=COB-ID used by RPDO @@ -635,7 +656,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1401sub1] ParameterName=COB-ID used by RPDO @@ -668,7 +689,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1402sub1] ParameterName=COB-ID used by RPDO @@ -701,7 +722,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1403sub1] ParameterName=COB-ID used by RPDO @@ -734,7 +755,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1404sub1] ParameterName=COB-ID used by RPDO @@ -767,7 +788,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1405sub1] ParameterName=COB-ID used by RPDO @@ -800,7 +821,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1406sub1] ParameterName=COB-ID used by RPDO @@ -833,7 +854,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1407sub1] ParameterName=COB-ID used by RPDO @@ -866,7 +887,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1408sub1] ParameterName=COB-ID used by RPDO @@ -899,7 +920,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1409sub1] ParameterName=COB-ID used by RPDO @@ -932,7 +953,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [140Asub1] ParameterName=COB-ID used by RPDO @@ -965,7 +986,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [140Bsub1] ParameterName=COB-ID used by RPDO @@ -998,7 +1019,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [140Csub1] ParameterName=COB-ID used by RPDO @@ -1031,7 +1052,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [140Dsub1] ParameterName=COB-ID used by RPDO @@ -1064,7 +1085,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [140Esub1] ParameterName=COB-ID used by RPDO @@ -1097,7 +1118,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [140Fsub1] ParameterName=COB-ID used by RPDO @@ -4211,7 +4232,7 @@ DefaultValue=0 ; ;States: ; 0x00: off -; 0x01: searching to satellites +; 0x01: searching for satellites ; 0x02: locked on >= 4 satellites ; 0xFF: failed ; @@ -4224,6 +4245,7 @@ ObjectType=0x07 DataType=0x0005 AccessType=rw DefaultValue=0x01 +PDOMapping=1 ;has the system time been sync'd to the time in the skytraq message [6000sub6] @@ -4232,6 +4254,7 @@ ObjectType=0x07 DataType=0x0001 AccessType=ro DefaultValue=0 +PDOMapping=1 [6001] ParameterName=SkyTraq Data @@ -4576,51 +4599,39 @@ ParameterName=Error status bits ObjectType=0x07 DataType=0x000A AccessType=ro -DefaultValue=00000000000000000000 +DefaultValue=00 00 00 00 00 00 00 00 00 00 [3000] -ParameterName=OLAF app control +ParameterName=Power control ObjectType=0x09 -SubNumber=5 +SubNumber=3 [3000sub0] ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x04 +DefaultValue=0x02 -;Write true to restart the board +;Write true to poweroff the system [3000sub1] -ParameterName=Reboot Board +ParameterName=Poweroff ObjectType=0x07 DataType=0x0001 AccessType=wo DefaultValue=0 -;Write true to poweroff the board +;1 for a soft reset (restart daemon) +;2 for hard reset (reboot the board) +;3 to do a factory reset (clear all caches and reboot) [3000sub2] -ParameterName=Poweroff Board -ObjectType=0x07 -DataType=0x0001 -AccessType=wo -DefaultValue=0 - -;Write true to have the OLAF app exit -[3000sub3] -ParameterName=Quit +ParameterName=Reset ObjectType=0x07 -DataType=0x0001 +DataType=0x0005 AccessType=wo DefaultValue=0 - -;Allow OLAF to control the board CPU frequency -[3000sub4] -ParameterName=CPU frequency -ObjectType=0x07 -DataType=0x0001 -AccessType=rw -DefaultValue=0 +LowLimit=0 +HighLimit=3 [3001] ParameterName=System info @@ -4640,7 +4651,6 @@ ParameterName=OS name ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the name of the OS distro running on the board [3001sub2] @@ -4648,7 +4658,6 @@ ParameterName=OS distro ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the version of the OS running on the board [3001sub3] @@ -4656,7 +4665,6 @@ ParameterName=OS kernel version ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the board hostname [3001sub4] @@ -4664,7 +4672,6 @@ ParameterName=hostname ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the uptime [3001sub5] @@ -4688,7 +4695,6 @@ ParameterName=CPU architecture ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the CPU power governor of the board [3001sub8] @@ -4696,7 +4702,6 @@ ParameterName=CPU governor ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the CPU frequency of the board [3001sub9] @@ -4733,7 +4738,6 @@ ParameterName=RemoteprocX name ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the state of selected remoteproc [3001subD] @@ -4741,7 +4745,6 @@ ParameterName=RemoteprocX state ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the 1 minute load average [3001subE] @@ -4919,7 +4922,6 @@ ParameterName=Filter ObjectType=0x07 DataType=0x0009 AccessType=rw -DefaultValue=x ;Length of the current cache selected with keyword filter [3002sub5] @@ -4947,7 +4949,6 @@ ParameterName=File name ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;File size for the selected place in the selected cache [3002sub8] @@ -4983,7 +4984,6 @@ ParameterName=File name ObjectType=0x07 DataType=0x0009 AccessType=rw -DefaultValue=x ;Data of the file selected in subindex 1 [3003sub2] @@ -4991,13 +4991,14 @@ ParameterName=File data ObjectType=0x07 DataType=0x000F AccessType=ro +DefaultValue=0 -;Clear subindexes 1 and 2 +;Gets the CRC32 of the file [3003sub3] -ParameterName=Reset +ParameterName=CRC32 ObjectType=0x07 -DataType=0x0001 -AccessType=wo +DataType=0x0007 +AccessType=ro DefaultValue=0 ;Delete the file selected in subindex 1 @@ -5011,14 +5012,14 @@ DefaultValue=0 [3004] ParameterName=Fwrite ObjectType=0x09 -SubNumber=4 +SubNumber=3 [3004sub0] ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x02 ;Name of the file to be written. Must be set before index 2. [3004sub1] @@ -5026,7 +5027,6 @@ ParameterName=File name ObjectType=0x07 DataType=0x0009 AccessType=rw -DefaultValue=x ;File data for the new file written. Must set subindex 1 before writing to this subindex. [3004sub2] @@ -5034,13 +5034,6 @@ ParameterName=File data ObjectType=0x07 DataType=0x000F AccessType=wo - -;Clear subindexes 1 and 2 -[3004sub3] -ParameterName=Reset -ObjectType=0x07 -DataType=0x0001 -AccessType=wo DefaultValue=0 [3005] @@ -5091,7 +5084,6 @@ ParameterName=App name ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x [3005sub6] ParameterName=Daemon state @@ -5100,14 +5092,33 @@ DataType=0x0005 AccessType=rw DefaultValue=0 -;Write any non-zero number to get system logs. Log will be place in fread cache. [3006] -ParameterName=Get log +ParameterName=New Record +ObjectType=0x09 +SubNumber=3 + +[3006sub0] +ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 -AccessType=rw +AccessType=const +DefaultValue=0x02 + +;This will make a compress tar archive of the full system logs. It will be add to the cache. +[3006sub1] +ParameterName=Make logs file +ObjectType=0x07 +DataType=0x0001 +AccessType=wo DefaultValue=0 +;Get the logs since boot as a string. +[3006sub2] +ParameterName=Get logs +ObjectType=0x07 +DataType=0x0009 +AccessType=ro + [3100] ParameterName=Updater ObjectType=0x09 @@ -5150,7 +5161,6 @@ ParameterName=List updates ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Write a non-zero value to start an update [3100sub4] diff --git a/oresat_gps/data/oresat_gps.eds b/oresat_gps/data/oresat_gps.eds index a8ed719..40d7ae0 100644 --- a/oresat_gps/data/oresat_gps.eds +++ b/oresat_gps/data/oresat_gps.eds @@ -110,7 +110,7 @@ AccessType=ro DefaultValue=0x00000000 [OptionalObjects] -SupportedObjects=85 +SupportedObjects=87 1=0x1002 2=0x1003 3=0x1005 @@ -126,76 +126,78 @@ SupportedObjects=85 13=0x1016 14=0x1017 15=0x1019 -16=0x1023 -17=0x1029 -18=0x1200 -19=0x1400 -20=0x1401 -21=0x1402 -22=0x1403 -23=0x1404 -24=0x1405 -25=0x1406 -26=0x1407 -27=0x1408 -28=0x1409 -29=0x140A -30=0x140B -31=0x140C -32=0x140D -33=0x140E -34=0x140F -35=0x1600 -36=0x1601 -37=0x1602 -38=0x1603 -39=0x1604 -40=0x1605 -41=0x1606 -42=0x1607 -43=0x1608 -44=0x1609 -45=0x160A -46=0x160B -47=0x160C -48=0x160D -49=0x160E -50=0x160F -51=0x1800 -52=0x1801 -53=0x1802 -54=0x1803 -55=0x1804 -56=0x1805 -57=0x1806 -58=0x1807 -59=0x1808 -60=0x1809 -61=0x180A -62=0x180B -63=0x180C -64=0x180D -65=0x180E -66=0x180F -67=0x1A00 -68=0x1A01 -69=0x1A02 -70=0x1A03 -71=0x1A04 -72=0x1A05 -73=0x1A06 -74=0x1A07 -75=0x1A08 -76=0x1A09 -77=0x1A0A -78=0x1A0B -79=0x1A0C -80=0x1A0D -81=0x1A0E -82=0x1A0F -83=0x1F80 -84=0x6000 -85=0x6001 +16=0x1021 +17=0x1022 +18=0x1023 +19=0x1029 +20=0x1200 +21=0x1400 +22=0x1401 +23=0x1402 +24=0x1403 +25=0x1404 +26=0x1405 +27=0x1406 +28=0x1407 +29=0x1408 +30=0x1409 +31=0x140A +32=0x140B +33=0x140C +34=0x140D +35=0x140E +36=0x140F +37=0x1600 +38=0x1601 +39=0x1602 +40=0x1603 +41=0x1604 +42=0x1605 +43=0x1606 +44=0x1607 +45=0x1608 +46=0x1609 +47=0x160A +48=0x160B +49=0x160C +50=0x160D +51=0x160E +52=0x160F +53=0x1800 +54=0x1801 +55=0x1802 +56=0x1803 +57=0x1804 +58=0x1805 +59=0x1806 +60=0x1807 +61=0x1808 +62=0x1809 +63=0x180A +64=0x180B +65=0x180C +66=0x180D +67=0x180E +68=0x180F +69=0x1A00 +70=0x1A01 +71=0x1A02 +72=0x1A03 +73=0x1A04 +74=0x1A05 +75=0x1A06 +76=0x1A07 +77=0x1A08 +78=0x1A09 +79=0x1A0A +80=0x1A0B +81=0x1A0C +82=0x1A0D +83=0x1A0E +84=0x1A0F +85=0x1F80 +86=0x6000 +87=0x6001 [1002] ParameterName=Manufacturer status register @@ -491,6 +493,22 @@ DataType=0x0005 AccessType=rw DefaultValue=0 +;A master node can read this for a copy of the node's EDS file +[1021] +ParameterName=Store EDS +ObjectType=0x07 +DataType=0x000F +AccessType=ro +DefaultValue=0 + +;Indicate the format of the Store EDS +[1022] +ParameterName=Store format +ObjectType=0x07 +DataType=0x0005 +AccessType=ro +DefaultValue=0 + [1023] ParameterName=OS command ObjectType=0x09 @@ -508,18 +526,21 @@ ParameterName=Command ObjectType=0x07 DataType=0x000F AccessType=rw +DefaultValue=0 [1023sub2] ParameterName=Status ObjectType=0x07 DataType=0x0005 AccessType=ro +DefaultValue=0 [1023sub3] ParameterName=Reply ObjectType=0x07 DataType=0x000F AccessType=ro +DefaultValue=0 [1029] ParameterName=Error behavior @@ -592,7 +613,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1400sub1] ParameterName=COB-ID used by RPDO @@ -625,7 +646,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1401sub1] ParameterName=COB-ID used by RPDO @@ -658,7 +679,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1402sub1] ParameterName=COB-ID used by RPDO @@ -691,7 +712,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1403sub1] ParameterName=COB-ID used by RPDO @@ -724,7 +745,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1404sub1] ParameterName=COB-ID used by RPDO @@ -757,7 +778,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1405sub1] ParameterName=COB-ID used by RPDO @@ -790,7 +811,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1406sub1] ParameterName=COB-ID used by RPDO @@ -823,7 +844,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1407sub1] ParameterName=COB-ID used by RPDO @@ -856,7 +877,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1408sub1] ParameterName=COB-ID used by RPDO @@ -889,7 +910,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [1409sub1] ParameterName=COB-ID used by RPDO @@ -922,7 +943,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [140Asub1] ParameterName=COB-ID used by RPDO @@ -955,7 +976,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [140Bsub1] ParameterName=COB-ID used by RPDO @@ -988,7 +1009,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [140Csub1] ParameterName=COB-ID used by RPDO @@ -1021,7 +1042,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [140Dsub1] ParameterName=COB-ID used by RPDO @@ -1054,7 +1075,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [140Esub1] ParameterName=COB-ID used by RPDO @@ -1087,7 +1108,7 @@ ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x05 [140Fsub1] ParameterName=COB-ID used by RPDO @@ -4201,7 +4222,7 @@ DefaultValue=0 ; ;States: ; 0x00: off -; 0x01: searching to satellites +; 0x01: searching for satellites ; 0x02: locked on >= 4 satellites ; 0xFF: failed ; @@ -4214,6 +4235,7 @@ ObjectType=0x07 DataType=0x0005 AccessType=rw DefaultValue=0x01 +PDOMapping=1 ;has the system time been sync'd to the time in the skytraq message [6000sub6] @@ -4222,6 +4244,7 @@ ObjectType=0x07 DataType=0x0001 AccessType=ro DefaultValue=0 +PDOMapping=1 [6001] ParameterName=SkyTraq Data @@ -4566,51 +4589,39 @@ ParameterName=Error status bits ObjectType=0x07 DataType=0x000A AccessType=ro -DefaultValue=00000000000000000000 +DefaultValue=00 00 00 00 00 00 00 00 00 00 [3000] -ParameterName=OLAF app control +ParameterName=Power control ObjectType=0x09 -SubNumber=5 +SubNumber=3 [3000sub0] ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x04 +DefaultValue=0x02 -;Write true to restart the board +;Write true to poweroff the system [3000sub1] -ParameterName=Reboot Board +ParameterName=Poweroff ObjectType=0x07 DataType=0x0001 AccessType=wo DefaultValue=0 -;Write true to poweroff the board +;1 for a soft reset (restart daemon) +;2 for hard reset (reboot the board) +;3 to do a factory reset (clear all caches and reboot) [3000sub2] -ParameterName=Poweroff Board -ObjectType=0x07 -DataType=0x0001 -AccessType=wo -DefaultValue=0 - -;Write true to have the OLAF app exit -[3000sub3] -ParameterName=Quit +ParameterName=Reset ObjectType=0x07 -DataType=0x0001 +DataType=0x0005 AccessType=wo DefaultValue=0 - -;Allow OLAF to control the board CPU frequency -[3000sub4] -ParameterName=CPU frequency -ObjectType=0x07 -DataType=0x0001 -AccessType=rw -DefaultValue=0 +LowLimit=0 +HighLimit=3 [3001] ParameterName=System info @@ -4630,7 +4641,6 @@ ParameterName=OS name ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the name of the OS distro running on the board [3001sub2] @@ -4638,7 +4648,6 @@ ParameterName=OS distro ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the version of the OS running on the board [3001sub3] @@ -4646,7 +4655,6 @@ ParameterName=OS kernel version ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the board hostname [3001sub4] @@ -4654,7 +4662,6 @@ ParameterName=hostname ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the uptime [3001sub5] @@ -4678,7 +4685,6 @@ ParameterName=CPU architecture ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the CPU power governor of the board [3001sub8] @@ -4686,7 +4692,6 @@ ParameterName=CPU governor ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the CPU frequency of the board [3001sub9] @@ -4723,7 +4728,6 @@ ParameterName=RemoteprocX name ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the state of selected remoteproc [3001subD] @@ -4731,7 +4735,6 @@ ParameterName=RemoteprocX state ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Get the 1 minute load average [3001subE] @@ -4909,7 +4912,6 @@ ParameterName=Filter ObjectType=0x07 DataType=0x0009 AccessType=rw -DefaultValue=x ;Length of the current cache selected with keyword filter [3002sub5] @@ -4937,7 +4939,6 @@ ParameterName=File name ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;File size for the selected place in the selected cache [3002sub8] @@ -4973,7 +4974,6 @@ ParameterName=File name ObjectType=0x07 DataType=0x0009 AccessType=rw -DefaultValue=x ;Data of the file selected in subindex 1 [3003sub2] @@ -4981,13 +4981,14 @@ ParameterName=File data ObjectType=0x07 DataType=0x000F AccessType=ro +DefaultValue=0 -;Clear subindexes 1 and 2 +;Gets the CRC32 of the file [3003sub3] -ParameterName=Reset +ParameterName=CRC32 ObjectType=0x07 -DataType=0x0001 -AccessType=wo +DataType=0x0007 +AccessType=ro DefaultValue=0 ;Delete the file selected in subindex 1 @@ -5001,14 +5002,14 @@ DefaultValue=0 [3004] ParameterName=Fwrite ObjectType=0x09 -SubNumber=4 +SubNumber=3 [3004sub0] ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 AccessType=const -DefaultValue=0x03 +DefaultValue=0x02 ;Name of the file to be written. Must be set before index 2. [3004sub1] @@ -5016,7 +5017,6 @@ ParameterName=File name ObjectType=0x07 DataType=0x0009 AccessType=rw -DefaultValue=x ;File data for the new file written. Must set subindex 1 before writing to this subindex. [3004sub2] @@ -5024,13 +5024,6 @@ ParameterName=File data ObjectType=0x07 DataType=0x000F AccessType=wo - -;Clear subindexes 1 and 2 -[3004sub3] -ParameterName=Reset -ObjectType=0x07 -DataType=0x0001 -AccessType=wo DefaultValue=0 [3005] @@ -5081,7 +5074,6 @@ ParameterName=App name ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x [3005sub6] ParameterName=Daemon state @@ -5090,14 +5082,33 @@ DataType=0x0005 AccessType=rw DefaultValue=0 -;Write any non-zero number to get system logs. Log will be place in fread cache. [3006] -ParameterName=Get log +ParameterName=New Record +ObjectType=0x09 +SubNumber=3 + +[3006sub0] +ParameterName=Highest sub-index supported ObjectType=0x07 DataType=0x0005 -AccessType=rw +AccessType=const +DefaultValue=0x02 + +;This will make a compress tar archive of the full system logs. It will be add to the cache. +[3006sub1] +ParameterName=Make logs file +ObjectType=0x07 +DataType=0x0001 +AccessType=wo DefaultValue=0 +;Get the logs since boot as a string. +[3006sub2] +ParameterName=Get logs +ObjectType=0x07 +DataType=0x0009 +AccessType=ro + [3100] ParameterName=Updater ObjectType=0x09 @@ -5140,7 +5151,6 @@ ParameterName=List updates ObjectType=0x07 DataType=0x0009 AccessType=ro -DefaultValue=x ;Write a non-zero value to start an update [3100sub4] diff --git a/oresat_gps/gpio.py b/oresat_gps/gpio.py deleted file mode 100644 index fdd60e9..0000000 --- a/oresat_gps/gpio.py +++ /dev/null @@ -1,60 +0,0 @@ -import os - - -class GPIOError(Exception): - '''Error with GPIO''' - - -class GPIO: - - def __init__(self, num: int): - - self._num = num - self._is_on = False # save on IO calls - - if not os.path.isdir(f'/sys/class/gpio/gpio{self._num}'): - raise GPIOError(f'gpio{num} does not exist') - - try: - with open('/sys/class/gpio/export', 'w') as f: - f.write(self._num) - with open('/sys/class/gpio/export', 'w') as f: - f.write(self._num) - except PermissionError: - pass # will always fail, tho it actually works - - with open(f'/sys/class/gpio/gpio{self._num}/direction', 'w') as f: - f.write('out') - - with open(f'/sys/class/gpio/gpio{self._num}/value', 'r') as f: - self._is_on = f.read() == '1' - - def on(self): - - if self._is_on: - return # already on - - with open(f'/sys/class/gpio/gpio{self._num}/value', 'w') as f: - f.write('1') - - self._is_on = True - - def off(self): - - if not self._is_on: - return # already off - - with open(f'/sys/class/gpio/gpio{self._num}/value', 'w') as f: - f.write('0') - - self._is_on = False - - @property - def is_on(self): - - return self._is_on - - @property - def num(self): - - return self._num diff --git a/oresat_gps/gps_resource.py b/oresat_gps/gps_resource.py index 78689cd..655ebe5 100644 --- a/oresat_gps/gps_resource.py +++ b/oresat_gps/gps_resource.py @@ -2,9 +2,8 @@ from enum import IntEnum from time import clock_settime, CLOCK_REALTIME -from olaf import Resource, scet_int_from_time, logger +from olaf import Resource, scet_int_from_time, logger, GPIO -from .gpio import GPIO from .skytraq import SkyTraq, NavData, FixMode, gps_datetime @@ -29,13 +28,17 @@ class GPSResource(Resource): INDEX_SKYTRAQ_CONTROL = 0x6000 INDEX_SKYTRAQ_DATA = 0x6001 - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) + def __init__(self, mock_skytraq: bool): + super().__init__() - self._gpio0 = None - self._gpio1 = None + self._gpio_skytraq = None + self._gpio_lna = None self._skytraq = None self._state = States.OFF + self._mock_skytraq = mock_skytraq + + if mock_skytraq: + logger.warning('mocking SkyTraq and GPIO power pins') self._uid = geteuid() if self._uid != 0: @@ -43,30 +46,29 @@ def __init__(self, *args, **kwargs): def on_start(self): - self.control_rec = self.od[self.INDEX_SKYTRAQ_CONTROL] - self.data_rec = self.od[self.INDEX_SKYTRAQ_DATA] + self.control_rec = self.node.od[self.INDEX_SKYTRAQ_CONTROL] + self.data_rec = self.node.od[self.INDEX_SKYTRAQ_DATA] + + self.node.add_sdo_read_callback(self.INDEX_SKYTRAQ_CONTROL, self._on_read) + self.node.add_sdo_write_callback(self.INDEX_SKYTRAQ_CONTROL, self._on_write) + + self.control_rec[ControlSubindex.MOCK.value].value = self._mock_skytraq # control subindexes - self.mock_obj = self.control_rec[ControlSubindex.MOCK.value] self.is_syncd_obj = self.control_rec[ControlSubindex.IS_SYNCD.value] self.status_obj = self.control_rec[ControlSubindex.STATUS.value] # make sure the flag for the time has been syncd is set to false self.is_syncd_obj.value = False - self.mock_obj.value = self.mock_hw - if self.mock_hw: - logger.warning('mocking SkyTraq') - else: - skytraq_pin = self.control_rec[ControlSubindex.SKYTRAQ_PIN.value].value - lna_pin = self.control_rec[ControlSubindex.LNA_PIN.value].value - self._gpio_skytraq = GPIO(skytraq_pin) - self._gpio_lna = GPIO(lna_pin) - self._skytraq_power_on() - + skytraq_pin = self.control_rec[ControlSubindex.SKYTRAQ_PIN.value].value + lna_pin = self.control_rec[ControlSubindex.LNA_PIN.value].value + self._gpio_skytraq = GPIO(skytraq_pin, self._mock_skytraq) + self._gpio_lna = GPIO(lna_pin, self._mock_skytraq) self._skytraq_power_on() + serial_bus = self.control_rec[ControlSubindex.SERIAL_BUS.value].value - self._skytraq = SkyTraq(serial_bus, self._new_message, self._new_error, self.mock_hw) + self._skytraq = SkyTraq(serial_bus, self._new_message, self._new_error, self._mock_skytraq) self._skytraq.start() self._state = States.SEARCHING @@ -75,15 +77,16 @@ def on_end(self): self._skytraq_power_off() self._state = States.OFF - def on_read(self, index, subindex, od): + def _on_read(self, index: int, subindex: int): + if index == self.INDEX_SKYTRAQ_CONTROL and subindex == ControlSubindex.STATUS: return self._state.value - def on_write(self, index, subindex, od, data): + def _on_write(self, index: int, subindex: int, value): if index == self.INDEX_SKYTRAQ_CONTROL and subindex == ControlSubindex.STATUS: # turn skytraq on/off - if od.decode_raw(data): + if value: self._skytraq_power_on() else: self._skytraq_power_off() @@ -109,10 +112,10 @@ def _new_message(self, nav_data: NavData): self.data_rec[0x14].value = scet_int_from_time(dt) # send gps tpdos - self.send_tpdo(2) - self.send_tpdo(3) - self.send_tpdo(4) - self.send_tpdo(5) + self.node.send_tpdo(2) + self.node.send_tpdo(3) + self.node.send_tpdo(4) + self.node.send_tpdo(5) # update status if nav_data.number_of_sv >= 4 and nav_data.fix_mode >= FixMode.FIX_2D: @@ -128,15 +131,13 @@ def _new_error(self, error: str): def _skytraq_power_on(self): logger.info('turning SkyTraq on') - if not self.mock_hw: - self._gpio_skytraq.on() - self._gpio_lna.on() + self._gpio_skytraq.high() + self._gpio_lna.high() self._state = States.SEARCHING def _skytraq_power_off(self): logger.info('turning SkyTraq off') - if not self.mock_hw: - self._gpio_skytraq.off() - self._gpio_lna.off() + self._gpio_skytraq.low() + self._gpio_lna.low() self._state = States.OFF diff --git a/oresat_gps/templates/skytraq.html b/oresat_gps/templates/skytraq.html index 136cd12..464e710 100644 --- a/oresat_gps/templates/skytraq.html +++ b/oresat_gps/templates/skytraq.html @@ -128,7 +128,7 @@

SkyTraq Data

km / s - UTC Timestamp + Timestamp (Local TZ) @@ -142,96 +142,99 @@

SkyTraq Data

3: '3D+DGPS', }; - const indexNames = { - '0x01': 'fixMode', - '0x02': 'numSv', - '0x03': 'gpsWeek', - '0x04': 'tow', - '0x05': 'lat', - '0x06': 'long', - '0x07': 'ellipAlt', - '0x08': 'meanSeaLevelAlt', - '0x09': 'gdop', - '0x0A': 'pdop', - '0x0B': 'hdop', - '0x0C': 'vdop', - '0x0D': 'tdop', - '0x0E': 'ecefX', - '0x0F': 'ecefY', - '0x10': 'ecefZ', - '0x11': 'ecefVx', - '0x12': 'ecefVy', - '0x13': 'ecefVz', - '0x14': 'timestamp', - }; - - const STATES = { - 0: 'OFF', - 1: 'SEARCHING', - 2: 'LOCKED_ON', - 255: 'FAILED', - }; + const subindexNames = { + 0x01: 'fixMode', + 0x02: 'numSv', + 0x03: 'gpsWeek', + 0x04: 'tow', + 0x05: 'lat', + 0x06: 'long', + 0x07: 'ellipAlt', + 0x08: 'meanSeaLevelAlt', + 0x09: 'gdop', + 0x0A: 'pdop', + 0x0B: 'hdop', + 0x0C: 'vdop', + 0x0D: 'tdop', + 0x0E: 'ecefX', + 0x0F: 'ecefY', + 0x10: 'ecefZ', + 0x11: 'ecefVx', + 0x12: 'ecefVy', + 0x13: 'ecefVz', + 0x14: 'timestamp', + }; + + const STATES = { + 0: 'OFF', + 1: 'SEARCHING', + 2: 'LOCKED_ON', + 255: 'FAILED', + }; - async function updateStatic() { - let obj = await readValue('0x6000', '0x01'); - document.getElementById('serialBus').textContent = obj['value']; - obj = await readValue('0x6000', '0x02'); - document.getElementById('gpio0').textContent = obj['value']; - obj = await readValue('0x6000', '0x03'); - document.getElementById('gpio1').textContent = obj['value']; - obj = await readValue('0x6000', '0x04'); - document.getElementById('mock').textContent = obj['value']; - } + async function updateStatic() { + let obj = await readValue('0x6000', '0x01'); + document.getElementById('serialBus').textContent = obj['value']; + obj = await readValue('0x6000', '0x02'); + document.getElementById('gpio0').textContent = obj['value']; + obj = await readValue('0x6000', '0x03'); + document.getElementById('gpio1').textContent = obj['value']; + obj = await readValue('0x6000', '0x04'); + document.getElementById('mock').textContent = obj['value']; + } + + const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; - async function updateAll() { - for (const index in indexNames) { - const obj = await readValue('0x6001', index); - const tmp = document.getElementById(indexNames[index]); + async function updateAll() { + let obj = await readValue('0x6001', null); + for (const subindex in subindexNames) { + const tmp = document.getElementById(subindexNames[subindex]); + let sub_obj = obj.subindexes[subindex]; - switch(index) { - case '0x01': - tmp.textContent = FIX_MODES[obj['value']]; - break; - case '0x05': - case '0x06': - tmp.textContent = (obj['value'] / 1e7).toFixed(3); - break; - case '0x07': - case '0x08': - case '0x09': - case '0x0A': - case '0x0B': - case '0x0C': - case '0x0D': - tmp.textContent = (obj['value'] * 0.01).toFixed(2); - break; - case '0x0E': - case '0x0F': - case '0x10': - case '0x11': - case '0x12': - case '0x13': - tmp.textContent = (obj['value'] / 100000).toFixed(3); - break; - case '0x14': - const d = scetToDate(obj['value']); - tmp.textContent = d.toLocaleString('en-US', { timeZone: 'UTC' }); - break; - default: - tmp.textContent = obj['value']; + switch(parseInt(subindex)) { + case 0x01: + tmp.textContent = FIX_MODES[sub_obj.value]; + break; + case 0x05: + case 0x06: + tmp.textContent = (sub_obj.value / 1e7).toFixed(3); + break; + case 0x07: + case 0x08: + case 0x09: + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0D: + tmp.textContent = (sub_obj.value * 0.01).toFixed(2); + break; + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + tmp.textContent = (sub_obj.value / 100000).toFixed(3); + break; + case 0x14: + const d = scetToDate(sub_obj.value); + tmp.textContent = d.toLocaleString('en-US', { timeZone: timezone }); + break; + default: + tmp.textContent = sub_obj.value; + } } + + obj = await readValue('0x6000', '0x05'); + document.getElementById('status').textContent = STATES[obj.value]; + obj = await readValue('0x6000', '0x06'); + document.getElementById('timeSyncd').textContent = obj.value; } - - let obj = await readValue('0x6000', '0x05'); - document.getElementById('status').textContent = STATES[obj['value']]; - obj = await readValue('0x6000', '0x06'); - document.getElementById('timeSyncd').textContent = obj['value']; - } - updateStatic(); - updateAll(); - const interval = setInterval(function() { - updateAll() - }, 10000); - + updateStatic(); + updateAll(); + const interval = setInterval(function() { + updateAll(); + }, 10000); + {% endblock %} diff --git a/requirements.txt b/requirements.txt index 07e1773..37ca4f5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -oresat-olaf>=0.3.0 -pyserial build flake8 +oresat-olaf>=2.0.0 +pyserial diff --git a/setup.cfg b/setup.cfg index 4b1d32d..f46e9be 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,7 +24,7 @@ classifiers = [options] packages = find: install_requires = - oresat-olaf>=1.0.0 + oresat-olaf>=2.0.0 pyserial python_requires = >=3.7