• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kstars

ApnSerial_NET.cpp

Go to the documentation of this file.
00001 // ApnSerial_NET.cpp: implementation of the CApnSerial_NET class.
00002 //
00004 
00005 #include "stdafx.h"
00006 #include "apogee.h"
00007 #include "ApnSerial_NET.h"
00008 
00009 #include "ApogeeNet.h"
00010 #include "ApogeeNetErr.h"
00011 
00012 
00013 #ifdef _DEBUG
00014 #undef THIS_FILE
00015 static char THIS_FILE[]=__FILE__;
00016 #define new DEBUG_NEW
00017 #endif
00018 
00020 // Construction/Destruction
00022 
00023 CApnSerial_NET::CApnSerial_NET()
00024 {
00025     m_SerialId = -1;
00026 }
00027 
00028 CApnSerial_NET::~CApnSerial_NET()
00029 {
00030 
00031 }
00032 
00033 bool CApnSerial_NET::InitPort( unsigned long  CamIdA, 
00034                                unsigned short CamIdB,
00035                                unsigned short SerialId )
00036 {
00037     char            Hostname[25];
00038     BYTE            ipAddr[4];
00039 
00040 
00041     ipAddr[0] = (BYTE)(CamIdA & 0xFF);
00042     ipAddr[1] = (BYTE)((CamIdA >> 8) & 0xFF);
00043     ipAddr[2] = (BYTE)((CamIdA >> 16) & 0xFF);
00044     ipAddr[3] = (BYTE)((CamIdA >> 24) & 0xFF);
00045 
00046     sprintf( Hostname, "%u.%u.%u.%u", ipAddr[3], ipAddr[2], ipAddr[1], ipAddr[0] );
00047 
00048     if ( m_SerialId != -1 )
00049     {
00050         return false;
00051     }
00052 
00053     if ( (SerialId != 0) && (SerialId != 1) )
00054     {
00055         return false;
00056     }
00057 
00058     if ( ApnNetStartSockets() != APNET_SUCCESS )
00059         return false;
00060 
00061     if ( ApnNetSerialPortOpen( Hostname, CamIdB, SerialId ) != APNET_SUCCESS )
00062         return false;
00063 
00064     m_SerialId = SerialId;
00065 
00066     return true;
00067 }
00068 
00069 bool CApnSerial_NET::ClosePort()
00070 {
00071     if ( m_SerialId == -1 )
00072         return false;
00073 
00074     // just close the port and not care whether it was successful.  if it was,
00075     // great.  if not, we'll still set m_SerialId to -1 so that another call
00076     // can at least be tried to connect to the port.
00077     ApnNetSerialPortClose( m_SerialId );
00078 
00079     ApnNetStopSockets();
00080 
00081     m_SerialId = -1;
00082 
00083     return true;
00084 }
00085 
00086 bool CApnSerial_NET::GetBaudRate( unsigned long *BaudRate )
00087 {
00088     *BaudRate = -1;
00089 
00090     if ( m_SerialId == -1 )
00091         return false;
00092 
00093     /*
00094     unsigned long BaudRateRead;
00095 
00096 
00097     if ( m_SerialId == -1 )
00098         return false;
00099 
00100     if ( ApnNetSerialReadBaudRate(m_SerialId, &BaudRateRead) != APNET_SUCCESS )
00101         return false;
00102 
00103     *BaudRate = BaudRateRead;
00104     */
00105 
00106     return true;
00107 }
00108 
00109 bool CApnSerial_NET::SetBaudRate( unsigned long BaudRate )
00110 {
00111     if ( m_SerialId == -1 )
00112         return false;
00113 
00114     /*
00115     if ( ApnNetSerialWriteBaudRate(m_SerialId, BaudRate) != APNET_SUCCESS )
00116         return false;
00117     */
00118 
00119     return true;
00120 }
00121 
00122 bool CApnSerial_NET::GetFlowControl( Apn_SerialFlowControl *FlowControl )
00123 {
00124     *FlowControl = Apn_SerialFlowControl_Unknown;
00125 
00126     if ( m_SerialId == -1 )
00127         return false;
00128 
00129     /*
00130     bool FlowControlRead;
00131 
00132     if ( m_SerialId == -1 )
00133         return false;
00134 
00135     if ( ApnNetSerialReadFlowControl(m_SerialId, &FlowControlRead) != APNET_SUCCESS )
00136         return false;
00137     */
00138 
00139     return true;
00140 }
00141 
00142 bool CApnSerial_NET::SetFlowControl( Apn_SerialFlowControl FlowControl )
00143 {
00144     if ( m_SerialId == -1 )
00145         return false;
00146 
00147     /*
00148     if ( ApnNetSerialWriteFlowControl(m_SerialId, FlowControl) != APNET_SUCCESS )
00149         return false;
00150     */
00151 
00152     return true;
00153 }
00154 
00155 bool CApnSerial_NET::GetParity( Apn_SerialParity *Parity )
00156 {
00157     *Parity = Apn_SerialParity_Unknown;
00158 
00159     if ( m_SerialId == -1 )
00160         return false;
00161 
00162     /*
00163     ApnNetParity ParityRead;
00164         
00165     if ( m_SerialId == -1 )
00166         return false;
00167 
00168     if ( ApnNetSerialReadParity(m_SerialId, &ParityRead) != APNET_SUCCESS )
00169         return false;
00170 
00171     *Parity = (Apn_SerialParity)ParityRead;
00172     */
00173 
00174     return true;
00175 }
00176 
00177 bool CApnSerial_NET::SetParity( Apn_SerialParity Parity )
00178 {
00179     if ( m_SerialId == -1 )
00180         return false;
00181 
00182     /*
00183     if ( ApnNetSerialWriteParity(m_SerialId, (ApnNetParity)Parity) != APNET_SUCCESS )
00184         return false;
00185     */
00186 
00187     return true;
00188 }
00189 
00190 bool CApnSerial_NET::Read( char *ReadBuffer, unsigned short *ReadCount )
00191 {
00192     if ( m_SerialId == -1 )
00193         return false;
00194 
00195     if ( ApnNetSerialRead(m_SerialId, ReadBuffer, ReadCount) != APNET_SUCCESS )
00196     {
00197         *ReadCount = 0;
00198         return false;
00199     }
00200 
00201     return true;
00202 }
00203 
00204 bool CApnSerial_NET::Write( char *WriteBuffer, unsigned short WriteCount )
00205 {
00206     if ( m_SerialId == -1 )
00207         return false;
00208 
00209     if ( ApnNetSerialWrite(m_SerialId, WriteBuffer, WriteCount) != APNET_SUCCESS )
00210         return false;
00211 
00212     return true;
00213 }
00214 

kstars

Skip menu "kstars"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal