Nws yog ib qho system tswj hwm ntau yam kho vajtse thiab software.
TANGO tam sim no txhawb nqa 4 lub platform: Linux, Windows NT, Solaris thiab HP-UX.
Ntawm no peb yuav piav qhia txog kev ua haujlwm nrog Linux (Ubuntu 18.04)
Kuv tsis tuaj yeem tso nws los ntawm qhov chaws; Kuv tau siv cov duab npaj txhij ntawm TangoBox 9.3 los ua haujlwm.
Cov lus qhia piav qhia yuav ua li cas rau nruab los ntawm pob khoom.
Peb yuav txaus siab tsuas yog thawj ob lub ntsiab lus.
Txhawb cov lus programming
C
C ++
Java
JavaScript
Nab hab sej
matlab
Lab xam
Kuv ua haujlwm nrog nws hauv python & c ++. Ntawm no C ++ yuav siv ua piv txwv.
Tam sim no cia peb mus rau qhov kev piav qhia ntawm yuav ua li cas txuas lub cuab yeej rau TANGO thiab yuav ua li cas ua haujlwm nrog nws. Tus nqi yuav raug coj los ua piv txwv GPS neo-6m-0-001:
Raws li koj tuaj yeem pom hauv daim duab, peb txuas lub rooj tsavxwm rau PC ntawm UART CP2102. Thaum txuas nrog lub PC, lub cuab yeej tshwm /dev/ttyUSB[0-N], feem ntau /dev/ttyUSB0.
POGO
Tam sim no cia peb pib pogo, thiab tsim skeleton code rau kev ua hauj lwm nrog peb lub rooj tsavxwm.
pogo
Kuv twb tau tsim tus lej lawm, cia peb tsim nws dua File->New.
Peb tau txais cov hauv qab no:
Peb lub cuab yeej (nyob rau hauv lub neej yav tom ntej, los ntawm cov cuab yeej peb yuav txhais tau tias cov software ib feem) yog khoob thiab muaj ob txoj cai tswj hwm: State & raws li txoj cai.
Nws yuav tsum tau sau nrog cov yam ntxwv tsim nyog:
Cov cuab yeej cuab tam - lub neej ntawd qhov tseem ceeb uas peb hloov mus rau lub cuab yeej los pib nws; rau lub rooj tsavxwm GPS, koj yuav tsum hloov lub npe ntawm lub rooj tsavxwm hauv lub kaw lus com = "/dev/ttyUSB0" thiab com port ceev baudrade = 9600
Lus txib - cov lus txib los tswj peb lub cuab yeej; lawv tuaj yeem muab cov lus sib cav thiab tus nqi rov qab.
LUB XEEV - rov qab lub xeev tam sim no, los ntawm Xeev
TSWV YIM - rov qab cov xwm txheej tam sim no, qhov no yog txoj hlua ntxiv rau LUB XEEV
GPSArray - rov qab los gps txoj hlua hauv daim ntawv DevVarCharArray
Tom ntej no, teeb tsa tus cwj pwm ntaus ntawv uas tuaj yeem nyeem / sau rau / los ntawm nws. Scalar Attributes - yam ntxwv yooj yim (char, hlua, ntev, thiab lwm yam) Spectrum yam ntxwv - ib-dimensional arrays Duab cwj pwm - ob-dimensional arrays
Xeev - lub xeev uas peb lub cuab yeej nyob.
QHIB - lub cuab yeej qhib.
ZE - lub cuab yeej kaw.
FAILT - yuam kev.
ON - tau txais cov ntaub ntawv los ntawm lub cuab yeej.
OFF - tsis muaj ntaub ntawv los ntawm lub cuab yeej.
Piv txwv ntawm kev ntxiv tus cwj pwm gps_string:
Lub sijhawm pov npav lub sij hawm hauv ms, ntau npaum li cas tus nqi gps_string yuav hloov kho. Yog tias lub sijhawm hloov tshiab tsis tau teev tseg, tus cwj pwm yuav hloov kho tsuas yog thaum thov.
tshwm sim:
Tam sim no koj yuav tsum tsim cov cai File-> Tsim
Los ntawm lub neej ntawd, Makefile tsis yog tsim; thawj zaug koj yuav tsum kos lub thawv los tsim nws. Qhov no yog ua kom cov kev hloov pauv ua rau nws tsis raug tshem tawm thaum lub sijhawm tshiab. Tau tsim nws ib zaug thiab teeb tsa rau koj qhov project (sau npe muab tso ua ke cov yuam sij, cov ntaub ntawv ntxiv), koj tuaj yeem tsis nco qab txog nws.
Tam sim no cia peb mus rau programming. pogo nrog generated hauv qab no rau peb:
Peb yuav txaus siab rau NEO6M.cpp & NEO6M.h. Cia peb ua ib qho piv txwv ntawm chav kawm constructor:
NEO6M::NEO6M(Tango::DeviceClass *cl, string &s)
: TANGO_BASE_CLASS(cl, s.c_str())
{
/*----- PROTECTED REGION ID(NEO6M::constructor_1) ENABLED START -----*/
init_device();
/*----- PROTECTED REGION END -----*/ // NEO6M::constructor_1
}
Dab tsi yog muaj thiab dab tsi tseem ceeb ntawm no? Lub init_device() muaj nuj nqi faib lub cim xeeb rau peb cov cwj pwm: gps_string & gps_cov, tab sis nws tsis tseem ceeb. Qhov tseem ceeb tshaj plaws ntawm no, cov no yog cov lus qhia:
/*----- PROTECTED REGION ID(NEO6M::constructor_1) ENABLED START -----*/
.......
/*----- PROTECTED REGION END -----*/ // NEO6M::constructor_1
Txhua yam uas nyob hauv qhov thaiv cov lus qhia no yuav tsis suav nrog hauv pogo thaum lub sijhawm rov tsim cov lej tom ntej txav deb!. Txhua yam uas tsis nyob hauv blocks yuav yog! Cov no yog qhov chaw uas peb tuaj yeem ua haujlwm thiab ua peb tus kheej hloov kho.
Tam sim no dab tsi yog lub luag haujlwm tseem ceeb hauv chav kawm? NEO 6 M:
Thaum peb xav nyeem tus cwj pwm tus nqi gps_string, cov haujlwm yuav raug hu ua raws li hauv qab no: always_executed_hook, nyeem_attr_hardware ΠΈ nyeem_gps_string. Read_gps_string yuav sau gps_string nrog tus nqi.
void NEO6M::read_gps_string(Tango::Attribute &attr)
{
DEBUG_STREAM << "NEO6M::read_gps_string(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(NEO6M::read_gps_string) ENABLED START -----*/
// Set the attribute value
*this->attr_gps_string_read = Tango::string_dup(this->gps.c_str());
attr.set_value(attr_gps_string_read);
/*----- PROTECTED REGION END -----*/ // NEO6M::read_gps_string
}
Muab tso ua ke
Mus rau qhov chaw folder thiab:
make
Qhov kev zov me nyuam yuav muab tso ua ke rau hauv ~ / DeviceServers folder.
tango-cs@tangobox:~/DeviceServers$ ls
NEO6M
JIVE
jive
Tseem muaj qee cov khoom siv hauv cov ntaub ntawv, cia tam sim no tsim peb li Kho kom raug-> Tsim Server
Tam sim no cia peb sim txuas rau nws:
Tsis muaj dab tsi yuav ua haujlwm, ua ntej peb yuav tsum khiav peb qhov program:
sudo ./NEO6M neo6m -v2
Kuv tsuas tuaj yeem txuas rau com chaw nres nkoj nrog txoj cai hauv paus-A. v - qib kev sau npe.
Tam sim no peb tuaj yeem txuas:
Neeg
Hauv cov duab, saib cov duab yeej zoo, tab sis koj xav tau qee yam muaj txiaj ntsig. Cia peb sau tus neeg siv khoom uas yuav txuas rau peb lub cuab yeej thiab nyeem los ntawm nws.
#include <tango.h>
using namespace Tango;
int main(int argc, char **argv) {
try {
//
// create a connection to a TANGO device
//
DeviceProxy *device = new DeviceProxy("NEO6M/neo6m/1");
//
// Ping the device
//
device->ping();
//
// Execute a command on the device and extract the reply as a string
//
vector<Tango::DevUChar> gps_array;
DeviceData cmd_reply;
cmd_reply = device->command_inout("GPSArray");
cmd_reply >> gps_array;
for (int i = 0; i < gps_array.size(); i++) {
printf("%c", gps_array[i]);
}
puts("");
//
// Read a device attribute (string data type)
//
string spr;
DeviceAttribute att_reply;
att_reply = device->read_attribute("gps_string");
att_reply >> spr;
cout << spr << endl;
vector<Tango::DevUChar> spr2;
DeviceAttribute att_reply2;
att_reply2 = device->read_attribute("gps_array");
att_reply2.extract_read(spr2);
for (int i = 0; i < spr2.size(); i++) {
printf("%c", spr2[i]);
}
puts("");
} catch (DevFailed &e) {
Except::print_exception(e);
exit(-1);
}
}