Bluetoothboard-ConnectionProgramm



  • Hey Leute,
    ich mache in Projekt in der SChule woch ich mit einem Bluetoothboard arbeite und ich komme bei einen Computerprogramm nicht mehr weiter da es immer einen Error anzeigt. Ich hab auch schon gegoogelt,aber da kam ich auch nicht weiter.
    Main:

    #include <windows.h>
    #include <winuser.h>
    #include <stdio.h>
    #include <conio.h>
    #include "hb625.h"
    
    #define BAUDRATE            9600
    #define TIMEOUT             5000 //ms
    #define POLLING_INTERVAL    1000 //ms
    
    unsigned char Com_Port_Number, Error, channel;
    
    BOOL Loop = TRUE;
    
    UINT idTimer;
    MSG msg;
    
    void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime);
    
    int main(void)
    {
    
      printf("Enter the HB625 com port number(1..255):");
      scanf("%d", &Com_Port_Number);
    
      //open com port
      if( !Open_HB625( Com_Port_Number, BAUDRATE, TIMEOUT ) )
      {
        printf("Can't open port!\n");
        return 1;
      }
    
      printf("\n\r");
    
      //start timer
      idTimer = SetTimer(NULL, 0, POLLING_INTERVAL, (TIMERPROC) TimerProc);
      if(  !idTimer )
      {
        printf("Can't start timer!");
        return 1;
      }
    
      while(Loop)
      {
    
        GetMessage(&msg, NULL, 0, 0);
        DispatchMessage(&msg);
    
        if( _kbhit() )
          Loop = FALSE;
    
      }
    
      KillTimer(NULL, idTimer);
      Close_HB625();
      return 0;
    }
    
    void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
    {
      if( Set_Digital_Output((1<<channel), &Error) )
      {
        printf("Digital output N%1d is ON;\r", channel+1);
    	if( channel < 7)
    	  channel++;
        else
    	  channel = 0;
      }
      else
      {
        printf("\n\rError: %d;\n", Error);
        Loop = FALSE;
      }
    }
    

    Die HB625-Header-Datei

    #ifndef _HB625_H_
    #define _HB625_H_
    
    #include <windows.h>
    
    #define ERR_NO		0 // no error
    #define ERR_TX		1 // Tx error
    #define ERR_RX		2 // Rx error
    #define ERR_CS		3 // control sum error
    #define ERR_PARAM	4 // parameters value error
    
    #ifdef _HB625_EXPORT_
    #define HB625_API  __declspec(dllexport)
    #else
    #define HB625_API  __declspec(dllimport)
    #endif
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    HB625_API BOOL WINAPI Open_HB625( unsigned char comport, long baudrate, long timeout );
    HB625_API BOOL WINAPI Close_HB625(void);
    HB625_API BOOL WINAPI Read_All_Channel( short int* Result_Array, unsigned char* error );
    HB625_API BOOL WINAPI Set_Digital_Output( unsigned char out, unsigned char* error );
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif /* _HB625_H_ */
    
    --------------------Configuration: mingw5 - CUI Debug, Builder Type: MinGW--------------------
    
    Checking file dependency...
    Compiling C:\Users\Florian\Documents\Schule\3ahit\PPM\C\Testprogramm1\c01.c...
    Linking...
    [Error] C:\Users\Florian\Documents\Schule\3ahit\PPM\C\Testprogramm1\c01.c:27: undefined reference to `_imp__Open_HB625@12'
    [Error] C:\Users\Florian\Documents\Schule\3ahit\PPM\C\Testprogramm1\c01.c:55: undefined reference to `_imp__Close_HB625@0'
    [Error] C:\Users\Florian\Documents\Schule\3ahit\PPM\C\Testprogramm1\c01.c:61: undefined reference to `_imp__Set_Digital_Output@8'
    [Error] collect2: ld returned 1 exit status
    
    Complete Make c01: 4 error(s), 0 warning(s)
    

    Er meldet immer das er diese Befehle für das Board nicht findet.
    Das programm hab ich nicht selber geschriebn sondern die waren bei dem Board dabei und da war auch das compilierte Prog. dabei.

    mfg Nar0x



  • Du musst dem Linker sagen, welche Bibliothek er linken soll. Wie genau das geht und welche das ist, hängt vom Compiler und der Bibliothek ab. (und #include hat damit nichts zu tun! Das sind verschiedene Sachen!)

    P.S. windows.h und Bluetooth ist auch einfach kein ISO C++ Thema!



  • Dieser Thread wurde von Moderator/in evilissimo aus dem Forum C++ in das Forum WinAPI verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.


Anmelden zum Antworten