Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Software Defined Radio
r0tor
Commits
1c8925d9
Commit
1c8925d9
authored
Jun 09, 2018
by
andz
Browse files
-- Added minimal implementation of hamlib
parent
4defb5a5
Pipeline
#11
canceled with stages
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
software/shackremote_arduino/hamlib.cpp
0 → 100644
View file @
1c8925d9
///
/// @file hamlib.cpp
/// @copyright Christian Obersteiner, Andreas Müller - CC-BY-SA 4.0
///
/// @brief Contains all kind of hamlib functions
///
#include "hamlib.h"
///
/// @brief Constructor
///
CHamlib
::
CHamlib
()
{
}
///
/// @brief Initialize Hamlib
///
void
CHamlib
::
initHamlib
(
EthernetUDP
*
udp
,
CRotor
*
rotor
)
{
udp_
=
udp
;
rotor_
=
rotor
;
}
///
/// @brief
///
void
CHamlib
::
receiveHamlibPacket
()
{
if
(
packet_received_
==
false
)
{
int
packet_size
=
udp_
->
parsePacket
();
if
(
packet_size
)
{
packet_received_
=
true
;
udp_
->
read
(
received_packet_
,
UDP_TX_PACKET_MAX_SIZE
);
parse_error_
=
parseHamlibPacket
();
}
}
}
///
/// @brief
///
void
CHamlib
::
sendHamlibPacket
()
{
if
(
packet_parsed_
)
{
udp_
->
beginPacket
(
udp_
->
remoteIP
(),
udp_
->
remotePort
());
udp_
->
write
(
tx_packet_
);
udp_
->
endPacket
();
packet_parsed_
=
false
;
}
}
///
/// @brief
///
CHamlib
::
hamlibError
CHamlib
::
parseHamlibPacket
()
{
packet_received_
=
false
;
if
(
received_packet_
==
"rotor state
\n
"
)
{
// Answer with max rotor values
sprintf
(
tx_packet_
,
"%f/%f %f/%f"
,
AZIM_MIN
,
AZIM_MAX
,
ELEV_MIN
,
ELEV_MAX
);
packet_parsed_
=
true
;
sendHamlibPacket
();
return
HAMLIB_OK
;
}
return
HAMLIB_NOK
;
}
///
/// @brief Serial Debug output Function
///
void
CHamlib
::
debugOut
()
{
Serial
.
print
(
"Contents: "
);
Serial
.
println
(
received_packet_
);
}
software/shackremote_arduino/hamlib.h
0 → 100644
View file @
1c8925d9
///
/// @file hamlib.h
/// @copyright Christian Obersteiner, Andreas Müller - CC-BY-SA 4.0
///
/// @brief Contains all kind of hamlib functions
///
#ifndef HAMLIB_H
#define HAMLIB_H
#include <Arduino.h>
#include <Ethernet.h>
#include "settings.h"
#include "rotor.h"
class
CHamlib
{
public:
enum
hamlibError
{
HAMLIB_OK
,
HAMLIB_NOK
};
CHamlib
();
void
initHamlib
(
EthernetUDP
*
udp
,
CRotor
*
rotor
);
void
receiveHamlibPacket
();
void
sendHamlibPacket
();
hamlibError
parseHamlibPacket
();
void
debugOut
();
private:
EthernetUDP
*
udp_
;
CRotor
*
rotor_
;
char
received_packet_
[
UDP_TX_PACKET_MAX_SIZE
];
char
tx_packet_
[
UDP_TX_PACKET_MAX_SIZE
];
bool
packet_received_
=
false
;
bool
packet_parsed_
=
false
;
hamlibError
parse_error_
=
HAMLIB_OK
;
};
#endif //HAMLIB_H
software/arduino/rotor.cpp
→
software/
shackremote_
arduino/rotor.cpp
View file @
1c8925d9
...
...
@@ -13,7 +13,7 @@
CRotor
::
CRotor
()
{
initRotor
();
initRotor
();
}
///
...
...
@@ -33,7 +33,7 @@ void CRotor::initRotor()
digitalWrite
(
AZIM_RE_CCW
,
HIGH
);
digitalWrite
(
AZIM_RE_BREAK
,
HIGH
);
//Initial Values
m_bAzimuthBreakReleased
=
0
;
m_bAzimuthBreakReleased
=
0
;
}
if
(
ELEV
)
{
...
...
@@ -42,11 +42,11 @@ void CRotor::initRotor()
pinMode
(
ELEV_RE_DWN
,
OUTPUT
);
pinMode
(
ELEV_RE_BREAK
,
OUTPUT
);
//All Relais Off
digitalWrite
(
ELEV_RE_UP
,
HIGH
);
digitalWrite
(
ELEV_RE_DWN
,
HIGH
);
digitalWrite
(
ELEV_RE_BREAK
,
HIGH
);
//Initial Values
m_bElevationBreakReleased
=
0
;
digitalWrite
(
ELEV_RE_UP
,
HIGH
);
digitalWrite
(
ELEV_RE_DWN
,
HIGH
);
digitalWrite
(
ELEV_RE_BREAK
,
HIGH
);
//Initial Values
m_bElevationBreakReleased
=
0
;
}
}
...
...
software/arduino/rotor.h
→
software/
shackremote_
arduino/rotor.h
View file @
1c8925d9
...
...
@@ -30,14 +30,13 @@ public:
private:
rotorError
readRotSensors
();
uint16
readADC
(
int
);
uint16
m_uActualAzimuth
;
uint16
m_uActualElevation
;
uint16
m_uSetAzimuth
;
uint16
m_uSetElevation
;
byte
m_bAzimuthBreakReleased
;
byte
m_bElevationBreakReleased
;
};
#endif //ROTOR_H
\ No newline at end of file
software/arduino/settings.h
→
software/
shackremote_
arduino/settings.h
View file @
1c8925d9
...
...
@@ -8,6 +8,7 @@
#ifndef SETTINGS_H
#define SETTINGS_H
// MISC Settings
#define DEBUG
//// Rotor Settings
// Rotor present
...
...
software/arduino/shackremote.ino
→
software/
shackremote_
arduino/shackremote
_arduino
.ino
View file @
1c8925d9
...
...
@@ -12,20 +12,24 @@
#include <Ethernet.h>
#include "rotor.h"
#include "hamlib.h"
// Network Settings
/// @todo move to settings.h
byte
mac
[]
=
{
0xDE
,
0xAD
,
0xBE
,
0xEF
,
0x13
,
0x37
};
byte
mac
[]
=
{
0xDE
,
0xAD
,
0xBE
,
0xEF
,
0x13
,
0x37
};
IPAddress
ip
(
83
,
133
,
178
,
126
);
unsigned
int
localPort
=
51337
;
CRotor
rotor
;
EthernetUDP
Udp
;
CHamlib
hamlib
;
EthernetUDP
udp
;
int
debugTime
;
void
setup
()
{
// Init
rotor
.
initRotor
();
// Open serial communications and wait for port to open:
Serial
.
begin
(
19200
);
while
(
!
Serial
)
{
...
...
@@ -34,22 +38,26 @@ void setup()
// start the Ethernet connection:
Ethernet
.
begin
(
mac
,
ip
);
Udp
.
begin
(
localPort
);
Serial
.
print
(
"Local IP: "
);
Serial
.
println
(
Ethernet
.
localIP
());
udp
.
begin
(
localPort
);
// init Hamlbib
hamlib
.
initHamlib
(
&
udp
,
&
rotor
);
//Debug
debugTime
=
0
;
}
void
loop
()
{
rotor
.
doRotor
();
if
(
debugTime
>
100
)
{
rotor
.
debugOut
();
debugTime
=
0
;
}
debugTime
++
;
}
\ No newline at end of file
hamlib
.
receiveHamlibPacket
();
rotor
.
doRotor
();
hamlib
.
sendHamlibPacket
();
if
(
debugTime
>
100
)
{
hamlib
.
debugOut
();
rotor
.
debugOut
();
debugTime
=
0
;
}
debugTime
++
;
}
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