mirror of
https://github.com/brendanhaines/RasPi.git
synced 2025-04-04 07:44:52 -06:00
removes old, non-functional DSM2 code
This commit is contained in:
parent
dcc87999a3
commit
fb65faa26f
@ -1,63 +1,34 @@
|
||||
#include "DSM2.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "wiringSerial.h"
|
||||
#include <cstring>
|
||||
|
||||
#define VALUE_MASK 0x3FF
|
||||
|
||||
DSM2::DSM2( char* device, int mode )
|
||||
DSM2::DSM2( int mode )
|
||||
{
|
||||
|
||||
fd = serialOpen( device, 115200 );
|
||||
if( mode != 1024 && mode != 2048 ) mode = 1024;
|
||||
if( mode == 1024 )
|
||||
{
|
||||
valueSize = 10;
|
||||
valueMask = 0x3FF;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
valueSize = 11;
|
||||
valueMask = 0x7FF;
|
||||
}
|
||||
std::cout << "opening serial port..." << std::flush;
|
||||
fd = serialOpen( "/dev/ttyAMA0", 115200 );
|
||||
std::cout << "SUCCESS " << fd << std::endl;
|
||||
std::cout << "flushing serial..." << std::flush;
|
||||
serialFlush(fd);
|
||||
std::cout << "SUCCESS" << std::endl;
|
||||
}
|
||||
|
||||
bool DSM2::ready()
|
||||
{
|
||||
if( serialDataAvail( fd ) >= 16 ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void DSM2::update( bool block )
|
||||
void DSM2::update()
|
||||
{
|
||||
int i = 0;
|
||||
if( block )
|
||||
{
|
||||
while( !ready() );
|
||||
}
|
||||
else if( !ready() ) return;
|
||||
|
||||
for( i = 0; i < 8; i++ ) readNext();
|
||||
return;
|
||||
}
|
||||
|
||||
void DSM2::readNext()
|
||||
{
|
||||
int channel, value, raw;
|
||||
raw = ( serialGetchar( fd ) << 8 ) + serialGetchar( fd );
|
||||
|
||||
if( lastReadChan == chanBeforeFl )
|
||||
{
|
||||
frameLoss = raw << 1 >> 1;
|
||||
lastReadChan = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
channel = (raw & 0x7FFF) >> valueSize;
|
||||
value = raw & valueMask;
|
||||
values[ channel ] = value;
|
||||
|
||||
lastReadChan = channel;
|
||||
|
||||
if( serialDataAvail(fd) < 16 ) return;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
data[ i ] = ( (int)(serialGetchar(fd)) << 8 ) + serialGetchar(fd);
|
||||
|
||||
*(values + 0) = data[7] & VALUE_MASK; //Throttle
|
||||
*(values + 1) = data[1] & VALUE_MASK; //Aileron
|
||||
*(values + 2) = data[3] & VALUE_MASK; //Elevator
|
||||
*(values + 3) = data[5] & VALUE_MASK; //Rudder
|
||||
*(values + 4) = data[4] & VALUE_MASK; //Gear
|
||||
*(values + 5) = data[2] & VALUE_MASK; //Aux1
|
||||
return;
|
||||
}
|
||||
|
@ -1,24 +1,18 @@
|
||||
#ifndef DSM2_H
|
||||
#define DSM2_H
|
||||
|
||||
#define chanBeforeFl -1
|
||||
|
||||
class DSM2 {
|
||||
class DSM2
|
||||
{
|
||||
public:
|
||||
DSM2( char* device = "/dev/ttyAMA0", int mode = 1024 );
|
||||
|
||||
bool ready();
|
||||
void update( bool block = false );
|
||||
void readNext();
|
||||
DSM2( int mode = 1024 );
|
||||
|
||||
int* values;
|
||||
int frameLoss;
|
||||
void update();
|
||||
int values[7];
|
||||
private:
|
||||
int lastReadChan;
|
||||
|
||||
int fd; // file descriptor for serial bus
|
||||
int valueSize; // number of bits for value part of frame
|
||||
int fd;
|
||||
int valueMask;
|
||||
char thisByte, lastByte;
|
||||
int data[7];
|
||||
};
|
||||
|
||||
#endif
|
@ -1,21 +1,15 @@
|
||||
#include <iostream>
|
||||
#include "DSM2.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
DSM2 dsm();
|
||||
|
||||
DSM2 dsm;
|
||||
while( true )
|
||||
{
|
||||
cout << "Thro" << dsm.values[0] <<
|
||||
"Aile" << dsm.values[1] <<
|
||||
"Elev" << dsm.values[2] <<
|
||||
"Rudd" << dsm.values[3] <<
|
||||
"Gear" << dsm.values[4] <<
|
||||
"Aux1" << dsm.values[5] <<
|
||||
"FL" << dsm.frameLoss << endl;
|
||||
|
||||
dsm.update( true );
|
||||
dsm.update();
|
||||
cout << "THRO " << dsm.values[0] << "\tAILE " << dsm.values[1] << "\tELEV " << dsm.values[2] << "\tRUDD " << dsm.values[3] << "\tGEAR " << dsm.values[4] << "\tAUX1 " << dsm.values[5] << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
all: PID.o I2Cdev.o MPU6050.o PCA9685.o DSM2.o main v2main PCA9685tester echoServerAdvanced
|
||||
all: PID.o I2Cdev.o MPU6050.o PCA9685.o DSM2.o PID.o
|
||||
|
||||
PCA_HDRS = PCA9685.h PCA9685_Addresses.h
|
||||
MPU_HDRS = helper_3dmath.h I2Cdev.h MPU6050_6Axis_MotionApps20.h MPU6050.h
|
||||
@ -11,11 +11,13 @@ CXXFLAGS = -DDMP_FIFO_RATE=9 -Wall -lwiringPi
|
||||
I2Cdev.o MPU6050.o PCA9685.o PID.o: $(HDRS)
|
||||
PCA9685tester.o echoServerAdvanced.o main.o: $(HDRS)
|
||||
|
||||
# version 2 stuff
|
||||
v2Parser.o: v2Parser.h helper_3dmath.h
|
||||
DSM2.o: $(DSM_HDRS)
|
||||
PID.o: $(PID_HDRS)
|
||||
|
||||
DSM2.o DSM2tester.o: $(DSM_HDRS)
|
||||
DSM2tester: DSM2tester.o DSM2.o
|
||||
$(CXX) $^ -lwiringPi -o $@
|
||||
|
||||
v2main.o: v2Parser.h $(PCA_HDRS) $(MPU_HDRS) $(PID_HDRS)
|
||||
v2main: v2main.o v2Parser.o PCA9685.o PID.o I2Cdev.o MPU6050.o DSM2.o
|
||||
$(CXX) $^ -lwiringPi -o $@
|
||||
@ -32,5 +34,9 @@ PCA9685tester: PCA9685.o PCA9685tester.o
|
||||
echoServerAdvanced: echoServerAdvanced.o PCA9685.o
|
||||
$(CXX) $^ -lwiringPi -o $@
|
||||
|
||||
SatelliteReceiver.o SatelliteReceiverTest.o: SatelliteReceiver.h
|
||||
SatelliteReceiverTest: SatelliteReceiver.o SatelliteReceiverTest.o
|
||||
$(CXX) $^ -lwiringPi -o $@
|
||||
|
||||
clean:
|
||||
rm I2Cdev.o MPU6050.o MPU6050dmp.o MPU6050dmp_tester.o MPU6050dmp_tester PID.o main.o main PCA9685tester
|
@ -1,8 +1,2 @@
|
||||
Copter Controller
|
||||
===
|
||||
Notes:
|
||||
---
|
||||
-DSM2 class does not work!
|
||||
--DSM2.cpp
|
||||
--DSM2.h
|
||||
--DSM2tester.cpp
|
@ -1,34 +0,0 @@
|
||||
#include "v2DSM2.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "wiringSerial.h"
|
||||
|
||||
#define VALUE_MASK 0x3FF
|
||||
|
||||
v2DSM2::v2DSM2( int mode )
|
||||
{
|
||||
std::cout << "opening serial port..." << std::flush;
|
||||
fd = serialOpen( "/dev/ttyAMA0", 115200 );
|
||||
std::cout << "SUCCESS " << fd << std::endl;
|
||||
std::cout << "flushing serial..." << std::flush;
|
||||
serialFlush(fd);
|
||||
std::cout << "SUCCESS" << std::endl;
|
||||
}
|
||||
|
||||
void v2DSM2::update()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if( serialDataAvail(fd) < 16 ) return;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
data[ i ] = ( (int)(serialGetchar(fd)) << 8 ) + serialGetchar(fd);
|
||||
|
||||
*(values + 0) = data[7] & VALUE_MASK; //Throttle
|
||||
*(values + 1) = data[1] & VALUE_MASK; //Aileron
|
||||
*(values + 2) = data[3] & VALUE_MASK; //Elevator
|
||||
*(values + 3) = data[5] & VALUE_MASK; //Rudder
|
||||
*(values + 4) = data[4] & VALUE_MASK; //Gear
|
||||
*(values + 5) = data[2] & VALUE_MASK; //Aux1
|
||||
return;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#ifndef V2DSM2_H
|
||||
#define V2DSM2_H
|
||||
|
||||
class v2DSM2
|
||||
{
|
||||
public:
|
||||
v2DSM2( int mode = 1024 );
|
||||
|
||||
void update();
|
||||
int values[7];
|
||||
private:
|
||||
int fd;
|
||||
int valueMask;
|
||||
char thisByte, lastByte;
|
||||
int data[7];
|
||||
};
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
#include <iostream>
|
||||
#include "v2DSM2.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
v2DSM2 dsm;
|
||||
while( true )
|
||||
{
|
||||
dsm.update();
|
||||
cout << "THRO " << dsm.values[0] << "\tAILE " << dsm.values[1] << "\tELEV " << dsm.values[2] << "\tRUDD " << dsm.values[3] << "\tGEAR " << dsm.values[4] << "\tAUX1 " << dsm.values[5] << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
2
setup.sh
2
setup.sh
@ -53,7 +53,7 @@ iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
|
||||
# save these settings
|
||||
sh -c "iptables-save > /etc/iptables.ipv4.nat"
|
||||
|
||||
# modify /etc/network/interfaces
|
||||
# modify /etc/network/interfaces (again)
|
||||
cat "up iptables-restore < /etc/iptables.ipv4.nat" >> /etc/network/interfaces
|
||||
|
||||
# update hostapd
|
||||
|
Loading…
x
Reference in New Issue
Block a user