Please help. I know how to use CHARTEVENT_KEYDOWN to get the key pressed and to use that to program an action for the key. However, I would like to program extra shortcuts to make use of existing MT4 interface functions and cannot find the appropriate programming language for it. If you want to create a trendline in MT4, you can click on the trendline button which puts MT4 in trendline drawing mode. I want to be able to press "l" and then have my code put the platform in trendline drawing mode. Please can you point me to the appropriate command to put MT4 into trendline drawing mode?
You can use the WinAPI PostMessageW() function to do the task.
You can use #include <WinUser32.mqh> to import the WinAPI function descriptions.
Then you can use these commands to perform the task you need.
(For trendline #define MT4_WMCMD_TRENDLINE 33257)
Here you can find the commands
#define MT4_WMCMD_AUTOSCROLL 33017
#define MT4_WMCMD_BARS 33018
#define MT4_WMCMD_CANDLES 33019
/* 33020 unknown */
#define MT4_WMCMD_GRID 33021
#define MT4_WMCMD_LINE 33022
#define MT4_WMCMD_SHIFT 33023
#define MT4_WMCMD_VOLUMES 33024
#define MT4_WMCMD_ZOOM_IN 33025
#define MT4_WMCMD_ZOOM_OUT 33026
/* 33027-33047 unknown */
#define MT4_WMCMD_EXPERT_INPUTS 33048 /* Open expert Inputs dialog */
/* 33049 unknown */
#define MT4_WMCMD_REMOVE_EXPERT 33050 /* Remove expert advisor from chart */
/* 33051-33053 unknown */
#define MT4_WMCMD_SAVE_AS_PICTURE 33054
#define MT4_WMCMD_3_MONTHS 33057
#define MT4_WMCMD_ALL_HISTORY 33058
#define MT4_WMCMD_LAST_MONTH 33063
#define MT4_WMCMD_SAVE_Statement 33064
/* 33055-33133 unknown */
#define MT4_WMCMD_PERIOD_D1 33134
/* 33135 unknown */
#define MT4_WMCMD_PERIOD_H4 33136
#define MT4_WMCMD_PERIOD_M1 33137
#define MT4_WMCMD_PERIOD_M5 33138
#define MT4_WMCMD_PERIOD_M15 33139
#define MT4_WMCMD_PERIOD_M30 33140
#define MT4_WMCMD_PERIOD_W1 33141
/* 33142-33156 unknown */
#define MT4_WMCMD_PROPERTIES 33157 /* Chart Properties (F8) */
/* 33158-33176 apparently unused */
#define MT4_WMCMD_PERIOD_SEPARATE 33177 /* Show/hide period separators */
/* 33178-33196 unknown */
#define MT4_WMCMD_MOVE_RIGHT 33197 /* Move right (right/down arrow) */
#define MT4_WMCMD_MOVE_LEFT 33198 /* Move left (left/up arrow) */
/* 33199-33219 unknown */
#define MT4_WMCMD_SAVE_TEMPLATE 33220 /* Save template... */
/* 33221-33229 unknown */
#define MT4_WMCMD_33230 33230 /* Arrow Down */
#define MT4_WMCMD_33231 33231 /* Arrow Up */
#define MT4_WMCMD_33232 33232 /* icons-ticks */
#define MT4_WMCMD_MOUSE_CROSS 33233 /* crosshair */
#define MT4_WMCMD_MOUSE_CURSOR 33234 /* the cursor */
#define MT4_WMCMD_33235 33235 /* Box-cyclical Line */
#define MT4_WMCMD_33236 33236 /* equidistant channel */
#define MT4_WMCMD_33237 33237 /* Fibonacci lines */
#define MT4_WMCMD_33238 33238 /* Box-Fibonacci-arc */
#define MT4_WMCMD_33239 33239 /* Box-Fibonacci-fan */
#define MT4_WMCMD_33240 33240 /* Box Channels, Fibonacci */
#define MT4_WMCMD_33241 33241 /* Box-Gann-grid Hanna */
#define MT4_WMCMD_33242 33242 /* Box-Gann-line Hanna */
#define MT4_WMCMD_33243 33243 /* Box-Gann-fan Hanna */
#define MT4_WMCMD_HLINE 33244 /* horizontal line */
/* 33245 unknown */
#define MT4_WMCMD_33246 33246 /* Box Andrews pitchfork */
#define MT4_WMCMD_33247 33247 /* Box-shape-rectangle */
#define MT4_WMCMD_33248 33248 /* Box-channels-linear regression */
/* 33249-33250 apparently unused */
#define MT4_WMCMD_33251 33251 /* Box-icons-stop */
/* 33252 unknown */
#define MT4_WMCMD_33253 33253 /* text */
#define MT4_WMCMD_33254 33254 /* Box-icons-bad */
#define MT4_WMCMD_33255 33255 /* Box-icons-well */
#define MT4_WMCMD_33256 33256 /* Box-Fibonacci-time-zone */
#define MT4_WMCMD_TRENDLINE 33257 /* trend line */
#define MT4_WMCMD_33258 33258 /* Box-Line-trend line for the corner */
#define MT4_WMCMD_33259 33259 /* Box-figure-triangle */
#define MT4_WMCMD_VLINE 33260 /* Vertical Line */
#define MT4_WMCMD_LABEL 33261 /* text label */
/* 33262-33323 unknown */
#define MT4_WMCMD_UPDATE_DATA 33324 /* This doesn't cause experts start() to run */
/* 33325-33333 unknown */
#define MT4_WMCMD_PERIOD_MN1 33334 /* timeframe MN */
/* 33335-34299 unknown */
#define MT4_WMCMD_34300 34300 /* 34300-34699 custom indicators in alphabetical order */
#define MT4_WMCMD_34700 34700 /* Indicators-moving average of oscillator */
#define MT4_WMCMD_34701 34701 /* Indicators-accelerator oscillator */
#define MT4_WMCMD_34702 34702 /* Indicators-accumulation/distribution */
#define MT4_WMCMD_34703 34703 /* Indicators-alligator */
#define MT4_WMCMD_34704 34704 /* indicators-average directional movement index */
#define MT4_WMCMD_34705 34705 /* indicators-average true range */
#define MT4_WMCMD_34706 34706 /* Indicators-awesome oscillator */
#define MT4_WMCMD_34707 34707 /* Indicators-bears power */
#define MT4_WMCMD_34708 34708 /* indicator-bollinger bands */
#define MT4_WMCMD_34709 34709 /* Indicators-bulls power */
#define MT4_WMCMD_34710 34710 /* Indicators-commodity channel index */
#define MT4_WMCMD_34711 34711 /* Indicators-demarker */
#define MT4_WMCMD_34712 34712 /* Indicators-envelopes */
#define MT4_WMCMD_34713 34713 /* Indicators-force index */
#define MT4_WMCMD_34714 34714 /* Indicators-fractals */
#define MT4_WMCMD_34715 34715 /* Indicators-gator oscillator */
#define MT4_WMCMD_34716 34716 /* Indicators-ichimoku kinko hyo */
#define MT4_WMCMD_34717 34717 /* Indicators-macd */
#define MT4_WMCMD_34718 34718 /* indicators-market facilitation index */
#define MT4_WMCMD_34719 34719 /* Indicators-momentum */
#define MT4_WMCMD_34720 34720 /* indicators-money flow index */
#define MT4_WMCMD_34721 34721 /* indicators-moving averages */
#define MT4_WMCMD_34722 34722 /* Indicators-on balance volume */
#define MT4_WMCMD_34723 34723 /* Indicators-parabolic sar */
#define MT4_WMCMD_34724 34724 /* indicators-relative strength index */
#define MT4_WMCMD_34725 34725 /* indicators-relative vigor index */
#define MT4_WMCMD_34726 34726 /* Indicators-standard deviation */
#define MT4_WMCMD_34727 34727 /* Indicators-stochastic oscillator */
#define MT4_WMCMD_34728 34728 /* Indicators-volumes */
#define MT4_WMCMD_34729 34729 /* Indicators-william's percent range */
/* 34730-34799 unknown */
#define MT4_WMCMD_LOAD_TEMPLATE 34800 /* 34800-34899 load template in alphabetical order */
#define MT4_WMCMD_REMOVE_TEMPLATE 34900 /* 34900-34998 Remove Template in alph. order (conf. dialog) */
#define MT4_WMCMD_KILL_TEMPLATES 34999 /* remove *.tpl (confirmation dialog) */
/* 35000-35399 unknown */
#define MT4_WMCMD_PERIOD_H1 35400 /* timeframe H1 */
#define MT4_WMCMD_OBJECTS_LIST 35402 /* open objects list window */
#define MT4_WMCMD_ORDER_BUYLIMIT 35454 /* order buy limit */
#define MT4_WMCMD_ORDER_BUYSTOP 35455 /* order buy stop */
#define MT4_WMCMD_ORDER_SELLLIMIT 35456 /* order sell limit */
#define MT4_WMCMD_ORDER_SELLSTOP 35457 /* order sell stop */
#define MT4_WMCMD_ORDER_MARKET 35458 /* new order (F9) */
#define MT4_WMCMD_35464 35464 /* right price tag */
#define MT4_WMCMD_35511 35511 /* Graphic template-download template */
/* 35512-37011 unknown */
/* 37012-40000 not inspected */
#define MT4_WMCMD_57602 57602 /* close the current chart */
#define MT4_WMCMD_57603 57603 /* Save as (ascii/csv) */
#define MT4_WMCMD_57604 57604 /* Save as (ascii/csv) - apparently same */
#define MT4_WMCMD_PRINT_DIALOG 57607 /* Open Print... Dialog */
#define MT4_WMCMD_PRINT_DIRECT 57608 /* Print immediately */
#define MT4_WMCMD_PRINT_PREVIEW 57609 /* Open Print Preview dialog */
/* 57610-59675 unknown (re-checked up to 58011) */
/* 59675-... not inspected */
Related
want to add some Camera SDK in my swift project.. but cant solve this error..
libAndHeaders/MediaPlayer/G711Codec.h:42:1: error build: unknown type name 'class'; did you mean 'Class'?
maybe this is cpp header file or some other file. when i include this in my Objectice-c header file then it gives me this err..
/*
G711解码库
*/
#ifndef _G711_CODEC_H_
#define _G711_CODEC_H_
#define word16 short
#define word32 int
#define Word16 short
#define Word32 int
#define HI_VOICE_MAX_FRAME_SIZE (480+1) /* dont change it */
#define BIAS (0x84) /* Bias for linear code. */
#define CLIP 8159
#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */
#define QUANT_MASK (0xf) /* Quantization field mask. */
#define NSEGS (8) /* Number of A-law segments. */
#define SEG_SHIFT (4) /* Left shift for segment number. */
#define SEG_MASK (0x70) /* Segment field mask. */
static int seg_aend[8] = {0x1F, 0x3F, 0x7F, 0xFF,
0x1FF, 0x3FF, 0x7FF, 0xFFF};
static int seg_uend[8] = {0x3F, 0x7F, 0xFF, 0x1FF,
0x3FF, 0x7FF, 0xFFF, 0x1FFF};
/* HISI_VOICE codec type */
/* Real-time transport protocol(RTP) */
#define G711_A 0x01 /* 64kbps G.711 A, see RFC3551.txt 4.5.14 PCMA */
#define G711_U 0x02 /* 64kbps G.711 U, see RFC3551.txt 4.5.14 PCMU */
#define G711_ORG_A 0x41 /* original version 64kbps G.711 A */
#define G711_ORG_U 0x42 /* original version 64kbps G.711 U */
typedef int (*G711_Decoder)(int sample);
class G711Codec
{
check this screenshot
Yes, it´s a c++ header. You can mix obj-c and c++ if you need to (such source files need to have .mm extension, so that the compiler recognizes them), but probably you can choose another (obj-c) framework for what you need.
This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 3 years ago.
I'm working on an implementation of an EST(Enrollment over Secure Transport)-client over CoAPs for the OpenThread stack. For this, i want to write a CSR (Certificate Signing Request) by using mbedTLS, which is part of the stack as a third party software. My problem now is that i get some "undefined reference" error from the linker when i build the code (i'm using GCC on an Ubuntu 18.04.2 LTS machine).
As there are multiple functions for which the error occurs, i will provide code for just one example. here is my source file:
openthread/src/core/crypto/ecp.cpp:
#include "ecp.hpp"
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/ecp.h>
#include <mbedtls/pk.h>
#include "common/code_utils.hpp"
#include "common/debug.hpp"
#include "common/random.hpp"
#include "openthread/entropy.h"
#include "openthread/random_crypto.h"
namespace ot {
namespace Crypto {
#if OPENTHREAD_ENABLE_EST_CLIENT && OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
otError Ecp::KeyPairGeneration(const uint8_t *aPersonalSeed,
uint32_t aPersonalSeedLength,
uint8_t * aPrivateKey,
uint32_t * aPrivateKeyLength,
uint8_t * aPublicKey,
uint32_t * aPublicKeyLength)
{
otError error = OT_ERROR_NONE;
mbedtls_pk_context keypair;
OT_UNUSED_VARIABLE(aPersonalSeed);
OT_UNUSED_VARIABLE(aPersonalSeedLength);
mbedtls_pk_init(&keypair);
// Generate keypair
VerifyOrExit(mbedtls_pk_setup(&keypair, mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY)),
error = OT_ERROR_FAILED);
VerifyOrExit(mbedtls_ecp_group_load(&mbedtls_pk_ec(keypair)->grp, MBEDTLS_ECP_DP_SECP256R1) == 0,
error = OT_ERROR_FAILED);
VerifyOrExit(mbedtls_ecp_gen_keypair(&mbedtls_pk_ec(keypair)->grp, &mbedtls_pk_ec(keypair)->d,
&mbedtls_pk_ec(keypair)->Q, mbedtls_ctr_drbg_random,
Random::Crypto::MbedTlsContextGet()) == 0,
error = OT_ERROR_FAILED);
VerifyOrExit(mbedtls_pk_write_pubkey_pem(&keypair, (unsigned char*)aPublicKey,
*aPublicKeyLength) == 0,
error = OT_ERROR_INVALID_ARGS);
VerifyOrExit(mbedtls_pk_write_key_pem(&keypair, (unsigned char*)aPrivateKey,
*aPrivateKeyLength) == 0,
error = OT_ERROR_INVALID_ARGS);
exit:
mbedtls_pk_free(&keypair);
return error;
}
#endif // OPENTHREAD_ENABLE_EST_CLIENT
} // namespace Crypto
} // namespace ot
my header file:
openthread/src/core/crypto/ecp.hpp
#ifndef ECP_HPP_
#define ECP_HPP_
#include "openthread-core-config.h"
#include <stdint.h>
#include <stdlib.h>
#include <openthread/error.h>
namespace ot {
namespace Crypto {
/**
* #addtogroup core-security
*
* #{
*
*/
/**
* This class implements elliptic curve key generation.
*
*/
class Ecp
{
public:
/**
* This method generate a Elliptic Curve key pair.
*
* #param[in] aPersonalSeed An additional seed for the entropy. Can be NULL.
* #param[in] aPersonalSeedLengh The length of the #p aPersonalSeed.
* #param[out] aPrivateKey An output buffer where the private key should be stored.
* #param[inout] aPrivateKeyLength The length of the #p aPrivateKey buffer.
* #param[out] aPublicKey An output buffer where the private key should be stored.
* #param[inout] aPublicKeyLength The length of the #p aPublicKey buffer.
*
* #retval OT_ERROR_NONE EC key pairs has been created successfully.
* OT_ERROR_NO_BUFS Key buffers are too small or mbedtls heap too small.
*/
static otError KeyPairGeneration(const uint8_t *aPersonalSeed,
uint32_t aPersonalSeedLength,
uint8_t * aPrivateKey,
uint32_t * aPrivateKeyLength,
uint8_t * aPublicKey,
uint32_t * aPublicKeyLength);
};
/**
* #}
*
*/
} // namespace Crypto
} // namespace ot
#endif // ECP_HPP_
The functions which cause the error are here mbedtls_pk_write_pubkey_pem and mbedtls_pk_write_key_pem.
Here is also a part of the console output:
Making all in apps
Making all in cli
CC ot_cli_ftd-main.o
CC ot_cli_mtd-main.o
CCLD ot-cli-ftd
CCLD ot-cli-mtd
/opt/gcc-arm-none-eabi-8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: ../../../src/core/libopenthread-mtd.a(libopenthread_mtd_a-ecp.o): in function `ot::Crypto::Ecp::KeyPairGeneration(unsigned char const*, unsigned long, unsigned char*, unsigned long*, unsigned char*, unsigned long*)':
/home/scnm/eclipse-workspace/openthread/examples/../src/core/crypto/ecp.cpp:79: undefined reference to `mbedtls_pk_write_pubkey_pem'
/opt/gcc-arm-none-eabi-8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: /home/scnm/eclipse-workspace/openthread/examples/../src/core/crypto/ecp.cpp:83: undefined reference to `mbedtls_pk_write_key_pem'
collect2: error: ld returned 1 exit status
Makefile:1249: recipe for target 'ot-cli-mtd' failed
make[5]: *** [ot-cli-mtd] Error 1
I first thougth it was because i was missing some #define to actually use these functions, but i compared it with other OpenThread code which uses mbedtls and i can't see what i did wrong. As far as i've understood it, i have to modify the "openthread/third_party/mbedtls/mbedtls-config.h" file so that these funtions are build, so this is what i did:
#ifndef MBEDTLS_CONFIG_H
#define MBEDTLS_CONFIG_H
#include <stdio.h>
#include <stdlib.h>
#include <openthread/config.h>
#include <openthread/platform/logging.h>
#include <openthread/platform/memory.h>
#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf
#define MBEDTLS_AES_C
#define MBEDTLS_AES_ROM_TABLES
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_ASN1_WRITE_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_CCM_C
#define MBEDTLS_CIPHER_C
#define MBEDTLS_CMAC_C
#define MBEDTLS_CTR_DRBG_C
#define MBEDTLS_ECJPAKE_C
#define MBEDTLS_ECP_C
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
#define MBEDTLS_ECP_NIST_OPTIM
#define MBEDTLS_ENTROPY_C
#define MBEDTLS_HAVE_ASM
#define MBEDTLS_HMAC_DRBG_C
#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
#define MBEDTLS_MD_C
#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
#define MBEDTLS_NO_PLATFORM_ENTROPY
#define MBEDTLS_PK_C
#define MBEDTLS_PK_PARSE_C
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
#define MBEDTLS_SHA256_C
#define MBEDTLS_SHA256_SMALLER
#define MBEDTLS_SSL_CLI_C
#define MBEDTLS_SSL_DTLS_ANTI_REPLAY
#define MBEDTLS_SSL_DTLS_HELLO_VERIFY
#define MBEDTLS_SSL_EXPORT_KEYS
#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
#define MBEDTLS_SSL_PROTO_TLS1_2
#define MBEDTLS_SSL_PROTO_DTLS
#define MBEDTLS_SSL_TLS_C
#if OPENTHREAD_ENABLE_BORDER_AGENT || OPENTHREAD_ENABLE_COMMISSIONER || OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
#define MBEDTLS_SSL_COOKIE_C
#define MBEDTLS_SSL_SRV_C
#endif
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
#if OPENTHREAD_ENABLE_EST_CLIENT
#define MBEDTLS_PEM_WRITE_C
#define MBEDTLS_PK_WRITE_C
#define MBEDTLS_X509_CSR_WRITE_C
#define MBEDTLS_X509_CREATE_C
#endif
#endif
#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
#define MBEDTLS_BASE64_C
#define MBEDTLS_ECDH_C
#define MBEDTLS_ECDSA_C
#define MBEDTLS_OID_C
#define MBEDTLS_PEM_PARSE_C
#define MBEDTLS_X509_USE_C
#define MBEDTLS_X509_CRT_PARSE_C
#define MBEDTLS_X509_USE_C
#define MBEDTLS_X509_CRT_PARSE_C
#endif
#if OPENTHREAD_ENABLE_ECDSA
#define MBEDTLS_BASE64_C
#define MBEDTLS_ECDH_C
#define MBEDTLS_ECDSA_C
#define MBEDTLS_OID_C
#define MBEDTLS_PEM_PARSE_C
#endif
#define MBEDTLS_MPI_WINDOW_SIZE 1 /**< Maximum windows size used. */
#define MBEDTLS_MPI_MAX_SIZE 32 /**< Maximum number of bytes for usable MPIs. */
#define MBEDTLS_ECP_MAX_BITS 256 /**< Maximum bit size of groups */
#define MBEDTLS_ECP_WINDOW_SIZE 2 /**< Maximum window size used */
#define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Enable fixed-point speed-up */
#define MBEDTLS_ENTROPY_MAX_SOURCES 1 /**< Maximum number of sources supported */
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
#define MBEDTLS_PLATFORM_STD_CALLOC otPlatCAlloc /**< Default allocator to use, can be undefined */
#define MBEDTLS_PLATFORM_STD_FREE otPlatFree /**< Default free to use, can be undefined */
#else
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
#endif
#if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE
#define MBEDTLS_SSL_MAX_CONTENT_LEN 900 /**< Maxium fragment length in bytes */
#else
#define MBEDTLS_SSL_MAX_CONTENT_LEN 768 /**< Maxium fragment length in bytes */
#endif
#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
#if defined(MBEDTLS_USER_CONFIG_FILE)
#include MBEDTLS_USER_CONFIG_FILE
#endif
#if defined(MBEDTLS_ECP_ALT) && !defined(MBEDTLS_ECP_RESTARTABLE)
typedef void mbedtls_ecp_restart_ctx;
#endif
#include "mbedtls/check_config.h"
#endif /* MBEDTLS_CONFIG_H */
It resolved the "not defined in this scope" errors i've had before, but instead i have now the above described errors.
Here is what i've edited in the common-switch file:
openthread/examples/common-switches.mk
ECDSA ?= 0
// my code begin
EST_CLIENT ?= 0
// my code end
JAM_DETECTION ?= 0
ifeq ($(ECDSA),1)
configure_OPTIONS += --enable-ecdsa
endif
// my code begin
ifeq ($(EST_CLIENT),1)
configure_OPTIONS += --enable-est-client --enable-application-coap-secure
endif
// my code end
ifeq ($(JAM_DETECTION),1)
configure_OPTIONS += --enable-jam-detection
endif
and her what i've added to configure:
openthread/configure.ac
#
# EST Client
#
AC_ARG_ENABLE(est_client,
[AS_HELP_STRING([--enable-est-client],[Enable EST client support #<:#default=no#:>#.])],
[
case "${enableval}" in
no|yes)
enable_est_client=${enableval}
;;
*)
AC_MSG_ERROR([Invalid value ${enable_est_client} for --enable-est-client])
;;
esac
],
[enable_est_client=no])
if test "$enable_est_client" = "yes"; then
OPENTHREAD_ENABLE_EST_CLIENT=1
else
OPENTHREAD_ENABLE_EST_CLIENT=0
fi
AC_SUBST(OPENTHREAD_ENABLE_EST_CLIENT)
AM_CONDITIONAL([OPENTHREAD_ENABLE_EST_CLIENT], [test "${enable_est_client}" = "yes"])
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_EST_CLIENT],[${OPENTHREAD_ENABLE_EST_CLIENT}],[Define to 1 if you want to enable EST Client])
OpenThread DNS Client support : ${enable_dns_client}
// my code begin
OpenThread EST Client support : ${enable_est_client}
// my code end
OpenThread SNTP Client support : ${enable_sntp_client}
I've also edited the makefile:
openthread/src/core/Makefile.am
crypto/ecdsa.hpp \
crypto/ecp.hpp \
crypto/hmac_sha256.hpp \
crypto/ecdsa.cpp \
crypto/ecp.cpp \
crypto/hmac_sha256.cpp \
My build command is "make -f examples/Makefile-nrf52840 EST_CLIENT=1".
I think once this problem is solved, i can solve the others by myself as the root of the problem seems to be the same.
Thanks.
You have an error during the link, the symbol mbedtls_pk_write_pubkey_pem is not defined, that means you missed to specify the lib defining it. Looking on the web it seems you need to link with mbedcrypto, so add libmbedcrypto.a or -lmbedcrypto (and may be use the option -L to specify the path)
It seems you also use X509, if you have missing symbols *X509* link with mbedx509, so add libmbedx509.a or -lmbedx509 (and may be use the option -L to specify the path)
This question already has answers here:
Combining C++ and C - how does #ifdef __cplusplus work?
(4 answers)
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 4 years ago.
I have been working with C on the embedded side and C# on PC side for quite some time. Now I decided to start working with C++ on an embedded target.
However the linker tells me that it could not find my function.
The complete error looks like this:
Building target: Cpp_Test.elf
Invoking: MCU G++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -specs=nosys.specs -specs=nano.specs -T"../STM32F429ZITx_FLASH.ld" -Wl,-Map=output.map -Wl,--gc-sections -fno-exceptions -fno-rtti -o "Cpp_Test.elf" #"objects.list" -lm
Src/freertos.o: In function `StartDefaultTask':
\Cpp_Test\Debug/../Src/freertos.c:127: undefined reference to `calc_values'
The test_cplus.h file looks like this:
#include "stdint.h"
int calc_values();
The test_cplus.cpp file looks like this:
#include "test_cplus.h"
#include <iostream>
using namespace std;
class Rectangle {
int width, height;
public:
void set_values (int,int);
int area() {return width*height;}
};
void Rectangle::set_values (int x, int y) {
width = x;
height = y;
}
int calc_values()
{
Rectangle rect;
rect.set_values(1,2);
int area = rect.area();
return area;
}
Could you point me in the right direction?
Edit freertos.c
/* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
#include "cmsis_os.h"
/* USER CODE BEGIN Includes */
#include "test_file.h"
#include "test_cplus.h"
/* USER CODE END Includes */
/* Variables -----------------------------------------------------------------*/
osThreadId defaultTaskHandle;
/* USER CODE BEGIN Variables */
/* USER CODE END Variables */
/* Function prototypes -------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
void StartDefaultTask(void const * argument);
extern void MX_USB_DEVICE_Init(void);
extern void MX_FATFS_Init(void);
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
#ifdef __cplusplus
}
#endif
/* USER CODE BEGIN FunctionPrototypes */
/* USER CODE END FunctionPrototypes */
/* Hook prototypes */
/* Init FreeRTOS */
void MX_FREERTOS_Init(void) {
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* USER CODE BEGIN RTOS_MUTEX */
/* add mutexes, ... */
/* USER CODE END RTOS_MUTEX */
/* USER CODE BEGIN RTOS_SEMAPHORES */
/* add semaphores, ... */
/* USER CODE END RTOS_SEMAPHORES */
/* USER CODE BEGIN RTOS_TIMERS */
/* start timers, add new ones, ... */
/* USER CODE END RTOS_TIMERS */
/* Create the thread(s) */
/* definition and creation of defaultTask */
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */
/* USER CODE BEGIN RTOS_QUEUES */
/* add queues, ... */
/* USER CODE END RTOS_QUEUES */
}
/* StartDefaultTask function */
void StartDefaultTask(void const * argument)
{
/* init code for USB_DEVICE */
MX_USB_DEVICE_Init();
/* init code for FATFS */
MX_FATFS_Init();
/* USER CODE BEGIN StartDefaultTask */
/* Infinite loop */
for(;;)
{
run_test();
calc_values();
osDelay(100);
}
/* USER CODE END StartDefaultTask */
}
/* USER CODE BEGIN Application */
/* USER CODE END Application */
Im supposed to write a C++-programm that interacts with a uEye camera.
For this I have to include several files, one of them being a header file that has around 30 interfaces in it that are like the one shown below.
When I run a c++ programm including this header file, Im getting the error:
"error: expected identifier or '(' before ':' token"
at the first line (interface IuEyeAutoFeatures : public IUnknown) of every single interface in the header file.
Heres one of the interfaces from the header file:
interface IuEyeAutoFeatures : public IUnknown
{
STDMETHOD(SetAutoBrightnessReference)(long lReference) = 0;
STDMETHOD(GetAutoBrightnessReference)(long* plReference) = 0;
STDMETHOD(SetAutoBrightnessMaxExposure)(long lMaxExposure) = 0;
STDMETHOD(GetAutoBrightnessMaxExposure)(long* plMaxExposure) = 0;
STDMETHOD(SetAutoBrightnessMaxGain)(long lMaxGain) = 0;
STDMETHOD(GetAutoBrightnessMaxGain)(long* plMaxGain) = 0;
STDMETHOD(SetAutoBrightnessSpeed)(long lSpeed) = 0;
STDMETHOD(GetAutoBrightnessSpeed)(long* plSpeed) = 0;
STDMETHOD(SetAutoBrightnessAOI)(long lXPos, long lYPos, long lWidth, long lHeight) = 0;
STDMETHOD(GetAutoBrightnessAOI)(long* plXPos, long* plYPos, long* plWidth, long* plHeight) = 0;
STDMETHOD(SetAutoWBGainOffsets)(long lRedOffset, long lBlueOffset) = 0;
STDMETHOD(GetAutoWBGainOffsets)(long* plRedOffset, long* plBlueOffset) = 0;
STDMETHOD(SetAutoWBGainRange)(long lMinRGBGain, long lMaxRGBGain) = 0;
STDMETHOD(GetAutoWBGainRange)(long* plMinRGBGain, long* plMaxRGBGain) = 0;
STDMETHOD(SetAutoWBSpeed)(long lSpeed) = 0;
STDMETHOD(GetAutoWBSpeed)(long* plSpeed) = 0;
STDMETHOD(SetAutoWBAOI)(long lXPos, long lYPos, long lWidth, long lHeight) = 0;
STDMETHOD(GetAutoWBAOI)(long* plXPos, long* plYPos, long* plWidth, long* plHeight) = 0;
};
DEFINE_GUID(IID_IuEyeFaceDetection,
0xe122a994, 0xfc4d, 0x445b, 0xb2, 0x1c, 0x30, 0x8b, 0x67, 0x48, 0x44, 0xe0);
#ifndef DS_EXPORT
# define DS_EXPORT
# ifdef _UEYETIME
# undef _UEYETIME
# endif
# ifdef UEYETIME
# undef UEYETIME
# endif
typedef struct _UEYETIME
{
WORD wYear;
WORD wMonth;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
BYTE byReserved[10];
} UEYETIME;
#endif /* DS_EXPORT */
#ifndef DS_EXPORT
# define DS_EXPORT
# ifdef S_FDT_INFO_EL
# undef S_FDT_INFO_EL
# endif
# ifdef FDT_INFO_EL
# undef FDT_INFO_EL
# endif
/*!
* \brief uEye face detection info element data type.
* Info on a single detected face as listed by \see FDT_INFO_LIST.
*/
typedef struct S_FDT_INFO_EL
{
INT nFacePosX; /*!< \brief Start X position. */
INT nFacePosY; /*!< \brief Start Y position. */
INT nFaceWidth; /*!< \brief Face width. */
INT nFaceHeight; /*!< \brief Face height. */
INT nAngle; /*!< \brief Face Angle (0...360° clockwise, 0° at twelve o'clock position. -1: undefined ). */
UINT nPosture; /*!< \brief Face posture. */
UEYETIME TimestampSystem; /*!< \brief System time stamp (device query time) . */
UINT64 nReserved; /*!< \brief Reserved for future use. */
UINT nReserved2[4]; /*!< \brief Reserved for future use. */
} FDT_INFO_EL;
#endif /* DS_EXPORT */
#ifndef DS_EXPORT
# define DS_EXPORT
# ifdef S_FDT_INFO_LIST
# undef S_FDT_INFO_LIST
# endif
# ifdef FDT_INFO_LIST
# undef FDT_INFO_LIST
# endif
/*!
* \brief uEye face detection info list data type.
* List of detected faces, lists \see FDT_INFO_EL objects.
*/
typedef struct S_FDT_INFO_LIST
{
UINT nSizeOfListEntry; /*!< \brief Size of one list entry in byte(in). */
UINT nNumDetectedFaces; /*!< \brief Number of detected faces(out). */
UINT nNumListElements; /*!< \brief Number of list elements(in). */
UINT nReserved[4]; /*!< \brief reserved for future use(out). */
FDT_INFO_EL FaceEntry[1]; /*!< \brief First face entry. */
} FDT_INFO_LIST;
#endif /* DS_EXPORT */
As far as I know, declaring interfaces using the word "interface" is done in languages like Java but not in c++, so I dont understand why this header file declares interfaces like this. Since this header file is provided by the company IDS after downloading their driver it should be correct i suppose.
How can I fix that bug and make my program work?
Thanks in advance
interface is a preprocessor macro, commonly used with COM interfaces. It is defined in combaseapi.h as:
#define __STRUCT__ struct
#define interface __STRUCT__
You need to include that header file (either directly or indirectly through #include <objbase.h>) before including the interface header.
This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 9 years ago.
I did search and none of the answers really explained what I am seeing.
I had a file that was compiling correctly, and added a new include:
#include "libopencm3/stm32/usart.h"
Compile again and fine. Now, I add a function:
void usart_setup(void)
{
/* Setup USART6 parameters. */
usart_set_baudrate(USART6, 38400);
usart_set_databits(USART6, 8);
usart_set_stopbits(USART6, USART_STOPBITS_1);
usart_set_mode(USART6, USART_MODE_TX);
usart_set_parity(USART6, USART_PARITY_NONE);
usart_set_flow_control(USART6, USART_FLOWCONTROL_NONE);
/* Finally enable the USART. */
usart_enable(USART6);
}
Now I get:
/home/troy/projects/131114troy/tests/gpio1/trunk/gpio.c:137: undefined reference to `usart_set_baudrate'
/home/troy/projects/131114troy/tests/gpio1/trunk/gpio.c:138: undefined reference to `usart_set_databits'
/home/troy/projects/131114troy/tests/gpio1/trunk/gpio.c:139: undefined reference to `usart_set_stopbits'
/home/troy/projects/131114troy/tests/gpio1/trunk/gpio.c:140: undefined reference to `usart_set_mode'
/home/troy/projects/131114troy/tests/gpio1/trunk/gpio.c:141: undefined reference to `usart_set_parity'
/home/troy/projects/131114troy/tests/gpio1/trunk/gpio.c:142: undefined reference to `usart_set_flow_control'
/home/troy/projects/131114troy/tests/gpio1/trunk/gpio.c:145: undefined reference to `usart_enable'
Here is the usart.h file:
/*
* This file is part of the libopencm3 project.
*
* Copyright (C) 2009 Uwe Hermann <uwe#hermann-uwe.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBOPENCM3_USART_H
#define LIBOPENCM3_USART_H
#include <libopencm3/stm32/memorymap.h>
#include <libopencm3/cm3/common.h>
/* --- Convenience macros -------------------------------------------------- */
#define USART1 USART1_BASE
#define USART2 USART2_BASE
#define USART3 USART3_BASE
#define UART4 UART4_BASE
#define UART5 UART5_BASE
#define USART6 USART6_BASE
/* --- USART registers ----------------------------------------------------- */
/* Status register (USARTx_SR) */
#define USART_SR(usart_base) MMIO32(usart_base + 0x00)
#define USART1_SR USART_SR(USART1_BASE)
#define USART2_SR USART_SR(USART2_BASE)
#define USART3_SR USART_SR(USART3_BASE)
#define UART4_SR USART_SR(UART4_BASE)
#define UART5_SR USART_SR(UART5_BASE)
#define USART6_SR USART_SR(USART6_BASE)
/* Data register (USARTx_DR) */
#define USART_DR(usart_base) MMIO32(usart_base + 0x04)
#define USART1_DR USART_DR(USART1_BASE)
#define USART2_DR USART_DR(USART2_BASE)
#define USART3_DR USART_DR(USART3_BASE)
#define UART4_DR USART_DR(UART4_BASE)
#define UART5_DR USART_DR(UART5_BASE)
#define USART6_DR USART_DR(USART6_BASE)
/* Baud rate register (USARTx_BRR) */
#define USART_BRR(usart_base) MMIO32(usart_base + 0x08)
#define USART1_BRR USART_BRR(USART1_BASE)
#define USART2_BRR USART_BRR(USART2_BASE)
#define USART3_BRR USART_BRR(USART3_BASE)
#define UART4_BRR USART_BRR(UART4_BASE)
#define UART5_BRR USART_BRR(UART5_BASE)
#define USART6_BRR USART_BRR(USART6_BASE)
/* Control register 1 (USARTx_CR1) */
#define USART_CR1(usart_base) MMIO32(usart_base + 0x0c)
#define USART1_CR1 USART_CR1(USART1_BASE)
#define USART2_CR1 USART_CR1(USART2_BASE)
#define USART3_CR1 USART_CR1(USART3_BASE)
#define UART4_CR1 USART_CR1(UART4_BASE)
#define UART5_CR1 USART_CR1(UART5_BASE)
#define USART6_CR1 USART_CR1(USART6_BASE)
/* Control register 2 (USARTx_CR2) */
#define USART_CR2(usart_base) MMIO32(usart_base + 0x10)
#define USART1_CR2 USART_CR2(USART1_BASE)
#define USART2_CR2 USART_CR2(USART2_BASE)
#define USART3_CR2 USART_CR2(USART3_BASE)
#define UART4_CR2 USART_CR2(UART4_BASE)
#define UART5_CR2 USART_CR2(UART5_BASE)
#define USART6_CR2 USART_CR2(USART6_BASE)
/* Control register 3 (USARTx_CR3) */
#define USART_CR3(usart_base) MMIO32(usart_base + 0x14)
#define USART1_CR3 USART_CR3(USART1_BASE)
#define USART2_CR3 USART_CR3(USART2_BASE)
#define USART3_CR3 USART_CR3(USART3_BASE)
#define UART4_CR3 USART_CR3(UART4_BASE)
#define UART5_CR3 USART_CR3(UART5_BASE)
#define USART6_CR3 USART_CR3(USART6_BASE)
/* Guard time and prescaler register (USARTx_GTPR) */
#define USART_GTPR(usart_base) MMIO32(usart_base + 0x18)
#define USART1_GTPR USART_GTPR(USART1_BASE)
#define USART2_GTPR USART_GTPR(USART2_BASE)
#define USART3_GTPR USART_GTPR(USART3_BASE)
#define UART4_GTPR USART_GTPR(UART4_BASE)
#define UART5_GTPR USART_GTPR(UART5_BASE)
#define USART6_GTPR USART_GTPR(USART6_BASE)
/* --- USART_SR values ----------------------------------------------------- */
/* CTS: CTS flag */
/* Note: N/A on UART4/5 */
#define USART_SR_CTS (1 << 9)
/* LBD: LIN break detection flag */
#define USART_SR_LBD (1 << 8)
/* TXE: Transmit data buffer empty */
#define USART_SR_TXE (1 << 7)
/* TC: Transmission complete */
#define USART_SR_TC (1 << 6)
/* RXNE: Read data register not empty */
#define USART_SR_RXNE (1 << 5)
/* IDLE: Idle line detected */
#define USART_SR_IDLE (1 << 4)
/* ORE: Overrun error */
#define USART_SR_ORE (1 << 3)
/* NE: Noise error flag */
#define USART_SR_NE (1 << 2)
/* FE: Framing error */
#define USART_SR_FE (1 << 1)
/* PE: Parity error */
#define USART_SR_PE (1 << 0)
/* --- USART_DR values ----------------------------------------------------- */
/* USART_DR[8:0]: DR[8:0]: Data value */
#define USART_DR_MASK 0x1FF
/* --- USART_BRR values ---------------------------------------------------- */
/* DIV_Mantissa[11:0]: mantissa of USARTDIV */
#define USART_BRR_DIV_MANTISSA_MASK (0xFFF << 4)
/* DIV_Fraction[3:0]: fraction of USARTDIV */
#define USART_BRR_DIV_FRACTION_MASK 0xF
/* --- USART_CR1 values ---------------------------------------------------- */
/* UE: USART enable */
#define USART_CR1_UE (1 << 13)
/* M: Word length */
#define USART_CR1_M (1 << 12)
/* WAKE: Wakeup method */
#define USART_CR1_WAKE (1 << 11)
/* PCE: Parity control enable */
#define USART_CR1_PCE (1 << 10)
/* PS: Parity selection */
#define USART_CR1_PS (1 << 9)
/* PEIE: PE interrupt enable */
#define USART_CR1_PEIE (1 << 8)
/* TXEIE: TXE interrupt enable */
#define USART_CR1_TXEIE (1 << 7)
/* TCIE: Transmission complete interrupt enable */
#define USART_CR1_TCIE (1 << 6)
/* RXNEIE: RXNE interrupt enable */
#define USART_CR1_RXNEIE (1 << 5)
/* IDLEIE: IDLE interrupt enable */
#define USART_CR1_IDLEIE (1 << 4)
/* TE: Transmitter enable */
#define USART_CR1_TE (1 << 3)
/* RE: Receiver enable */
#define USART_CR1_RE (1 << 2)
/* RWU: Receiver wakeup */
#define USART_CR1_RWU (1 << 1)
/* SBK: Send break */
#define USART_CR1_SBK (1 << 0)
/* --- USART_CR2 values ---------------------------------------------------- */
/* LINEN: LIN mode enable */
#define USART_CR2_LINEN (1 << 14)
/* STOP[13:12]: STOP bits */
#define USART_CR2_STOPBITS_1 (0x00 << 12) /* 1 stop bit */
#define USART_CR2_STOPBITS_0_5 (0x01 << 12) /* 0.5 stop bits */
#define USART_CR2_STOPBITS_2 (0x02 << 12) /* 2 stop bits */
#define USART_CR2_STOPBITS_1_5 (0x03 << 12) /* 1.5 stop bits */
#define USART_CR2_STOPBITS_MASK (0x03 << 12)
#define USART_CR2_STOPBITS_SHIFT 12
/* CLKEN: Clock enable */
#define USART_CR2_CLKEN (1 << 11)
/* CPOL: Clock polarity */
#define USART_CR2_CPOL (1 << 10)
/* CPHA: Clock phase */
#define USART_CR2_CPHA (1 << 9)
/* LBCL: Last bit clock pulse */
#define USART_CR2_LBCL (1 << 8)
/* LBDIE: LIN break detection interrupt enable */
#define USART_CR2_LBDIE (1 << 6)
/* LBDL: LIN break detection length */
#define USART_CR2_LBDL (1 << 5)
/* ADD[3:0]: Addres of the usart node */
#define USART_CR2_ADD_MASK 0xF
/* --- USART_CR3 values ---------------------------------------------------- */
/* CTSIE: CTS interrupt enable */
/* Note: N/A on UART4 & UART5 */
#define USART_CR3_CTSIE (1 << 10)
/* CTSE: CTS enable */
/* Note: N/A on UART4 & UART5 */
#define USART_CR3_CTSE (1 << 9)
/* RTSE: RTS enable */
/* Note: N/A on UART4 & UART5 */
#define USART_CR3_RTSE (1 << 8)
/* DMAT: DMA enable transmitter */
/* Note: N/A on UART5 */
#define USART_CR3_DMAT (1 << 7)
/* DMAR: DMA enable receiver */
/* Note: N/A on UART5 */
#define USART_CR3_DMAR (1 << 6)
/* SCEN: Smartcard mode enable */
/* Note: N/A on UART4 & UART5 */
#define USART_CR3_SCEN (1 << 5)
/* NACK: Smartcard NACK enable */
/* Note: N/A on UART4 & UART5 */
#define USART_CR3_NACK (1 << 4)
/* HDSEL: Half-duplex selection */
#define USART_CR3_HDSEL (1 << 3)
/* IRLP: IrDA low-power */
#define USART_CR3_IRLP (1 << 2)
/* IREN: IrDA mode enable */
#define USART_CR3_IREN (1 << 1)
/* EIE: Error interrupt enable */
#define USART_CR3_EIE (1 << 0)
/* --- USART_GTPR values --------------------------------------------------- */
/* GT[7:0]: Guard time value */
/* Note: N/A on UART4 & UART5 */
#define USART_GTPR_GT_MASK (0xFF << 8)
/* PSC[7:0]: Prescaler value */
/* Note: N/A on UART4/5 */
#define USART_GTPR_PSC_MASK 0xFF
/* TODO */ /* Note to Uwe: what needs to be done here? */
/* --- Convenience defines ------------------------------------------------- */
/* CR1_PCE / CR1_PS combined values */
#define USART_PARITY_NONE 0x00
#define USART_PARITY_ODD USART_CR1_PS
#define USART_PARITY_EVEN (USART_CR1_PS | USART_CR1_PCE)
#define USART_PARITY_MASK (USART_CR1_PS | USART_CR1_PCE)
/* CR1_TE/CR1_RE combined values */
#define USART_MODE_RX USART_CR1_RE
#define USART_MODE_TX USART_CR1_TE
#define USART_MODE_TX_RX (USART_CR1_RE | USART_CR1_TE)
#define USART_MODE_MASK (USART_CR1_RE | USART_CR1_TE)
#define USART_STOPBITS_1 USART_CR2_STOPBITS_1 /* 1 stop bit */
#define USART_STOPBITS_0_5 USART_CR2_STOPBITS_0_5 /* 0.5 stop bits */
#define USART_STOPBITS_2 USART_CR2_STOPBITS_2 /* 2 stop bits */
#define USART_STOPBITS_1_5 USART_CR2_STOPBITS_1_5 /* 1.5 stop bits */
/* CR3_CTSE/CR3_RTSE combined values */
#define USART_FLOWCONTROL_NONE 0x00
#define USART_FLOWCONTROL_RTS USART_CR3_RTSE
#define USART_FLOWCONTROL_CTS USART_CR3_CTSE
#define USART_FLOWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE)
#define USART_FLOWCONTROL_MASK (USART_CR3_RTSE | USART_CR3_CTSE)
/* --- Function prototypes ------------------------------------------------- */
void usart_set_baudrate(u32 usart, u32 baud);
void usart_set_databits(u32 usart, u32 bits);
void usart_set_stopbits(u32 usart, u32 stopbits);
void usart_set_parity(u32 usart, u32 parity);
void usart_set_mode(u32 usart, u32 mode);
void usart_set_flow_control(u32 usart, u32 flowcontrol);
void usart_enable(u32 usart);
void usart_disable(u32 usart);
void usart_send(u32 usart, u16 data);
u16 usart_recv(u32 usart);
void usart_wait_send_ready(u32 usart);
void usart_wait_recv_ready(u32 usart);
void usart_send_blocking(u32 usart, u16 data);
u16 usart_recv_blocking(u32 usart);
void usart_enable_rx_dma(u32 usart);
void usart_disable_rx_dma(u32 usart);
void usart_enable_tx_dma(u32 usart);
void usart_disable_tx_dma(u32 usart);
#endif
If I comment out the line void usart_set_baudrate(u32 usart, u32 baud); I get an additional warning:
gpio.c:137:5: warning: implicit declaration of function 'usart_set_baudrate'
So it seems to be picking up the function at least in some way. Somewhat new to c++ so not too sure what else I can try. Any pointers?
Makefile:
# Name of the .c file with 'main' as well as output file name
NAME = gpio
# Linker file
LDFILE =stm32_flash.ld
# Current directory
CURDIR=.
SRCS = $(NAME).c startup_stm32f4xx.s syscalls.c
###################################################
# Check for valid float argument
# NOTE that you have to run make clean after
# changing these as hardfloat and softfloat are not
# binary compatible
ifneq ($(FLOAT_TYPE), hard)
ifneq ($(FLOAT_TYPE), soft)
override FLOAT_TYPE = soft
endif
endif
###################################################
# Prefix the name for the particular toolchain
PREFIX = arm-none-eabi-
TOOLDIR =~/CodeSourcery/Sourcery_G++_Lite/bin
CC =$(TOOLDIR)/$(PREFIX)gcc
LD =$(TOOLDIR)/$(PREFIX)ld
OBJCOPY =$(TOOLDIR)/$(PREFIX)objcopy
SIZE =$(TOOLDIR)/$(PREFIX)size
OBJDUMP =$(TOOLDIR)/$(PREFIX)objdump
CFLAGS = -std=gnu99 -g -Os -Wall
CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -nostartfiles -mcpu=cortex-m4
ifeq ($(FLOAT_TYPE), hard)
CFLAGS += -fsingle-precision-constant -Wdouble-promotion
CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
else
CFLAGS += -msoft-float
endif
###################################################
# Directory path--includes for .h and .c files common to all routines
LIBCOMMONALL = $(CURDIR)/../../../common_all/trunk
# Navigation to libraries specific to the f4 and discoveryf4
LIBF4D = $(CURDIR)/../../../sw_discoveryf4/trunk
# Routes to USB
LIBUSB = $(LIBF4D)/STM32F4_USB_CDC
# Includes--ST USB
CFLAGS += -I$(LIBUSB)/inc
CFLAGS += -I$(LIBUSB)/inc/StdPeriph/inc
CFLAGS += -I$(LIBUSB)/lib/StdPeriph/inc
CFLAGS += -I$(LIBUSB)/lib/USB_OTG/inc
CFLAGS += -I$(LIBUSB)/inc/USB_Device/Core/inc
CFLAGS += -I$(LIBUSB)/inc/USB_Device/Class/cdc/inc
CFLAGS += -I$(LIBUSB)/lib/Core/stm32
CFLAGS += -I$(LIBUSB)/lib/Core/cmsis
CFLAGS += -I$(LIBUSB)/lib/USB_Device/Class/cdc/inc
CFLAGS += -I$(LIBUSB)/lib/USB_Device/Core/inc/
# Includes--our stuff
CFLAGS += -I$(LIBCOMMONALL)
CFLAGS += -I$(LIBF4D)/lib/libdiscoveryf4
CFLAGS += -I$(LIBF4D)/lib/libmiscstm32f4
CFLAGS += -I$(LIBF4D)/lib/libusartstm32f4
CFLAGS += -I$(LIBF4D)/lib
# Library paths--ST USB
LIBPATHS = -L$(LIBUSB)
LIBPATHS += -L$(LIBUSB)/lib/StdPeriph
LIBPATHS += -L$(LIBUSB)/lib/USB_Device/Core
LIBPATHS += -L$(LIBUSB)/lib/USB_Device/Class/cdc
LIBPATHS += -L$(LIBUSB)/lib/USB_OTG
# Library paths--our stuff
LIBPATHS += -L$(LIBF4D)/lib/libdiscoveryf4
LIBPATHS += -L$(LIBF4D)/lib/libmiscstm32f4
LIBPATHS += -L$(LIBCOMMONALL)/stm32
# Libraries to link
# USB
LIBS = -lm -lusbf4 -lstdperiph -lusbdevcdc -lusbcore -lusbdevcore -lusbf4 -lstdperiph
# our stuff
LIBS += -ldiscoveryf4 -lmiscstm32f4
LDFLAGS = -T$(LDFILE)
OBJS = $(SRCS:.c=.o)
###################################################
.PHONY: proj
all: proj
$(SIZE) $(NAME).elf
proj: $(NAME).elf
$(NAME).elf: $(SRCS)
$(CC) $(CFLAGS) $^ -o $# $(LIBPATHS) $(LIBS) $(LDFLAGS)
$(OBJCOPY) -O ihex $(NAME).elf $(NAME).hex
$(OBJCOPY) -O binary $(NAME).elf $(NAME).bin
$(OBJDUMP) -S $(NAME).elf > $(NAME).list
clean:
rm -f *.o
rm -f $(NAME).elf
rm -f $(NAME).hex
rm -f $(NAME).bin
# $(MAKE) clean -C lib # Remove this line if you don't want to clean the libs as well
flash: images
#printf " FLASHING $(NAME)\n"
## IMPORTANT: Don't use "resume", only "reset" will work correctly!
# Kill running instances of the server
# killall st-util
st-flash write $(NAME).bin 0x08000000
.PHONY: images clean
It looks like you're not linking against a library that has the definition of those functions. usart.h is only providing the declarations, which tells the compiler the function(s) exist, but not what they actually do. It's the definitions that accomplish that. I imagine there's a usart.lib (or something similarly named) somewhere that needs to be added to your list of linked-in libraries.
I guess the problem is because you are not linking to the library.
make sure you have these three things in your make file:
-I header file path
-L library path
-llibraryname
these three things should be supplied as arguments to your compiler.