[oe] Question regarding a bitbake recipe for libmodbus

asdfasdf asdfasdf bluelotus256 at gmail.com
Fri Sep 30 16:12:10 UTC 2011


Hi
     hope you are doing well. I  am using a ARM based development
platform.I would appreciate it if you could answer a question I have
with regard to a
bitbake recipe for libmodbus:

I am trying to communicate with a plc which is a modbus slave through a C
program. The program just opens and closes the connection as I basically
wanted to test this function first before I proceeded any further:

# include "stdio.h"
# include "stdlib.h"
# include "modbus/modbus.h"

#define plc 0x01

int main(void)
{
modbus_param_t mb_param;

modbus_init_rtu(&mb_param,"/dev/ttyS2","none",8,1);

if (modbus_connect(&mb_param) == -1) {
printf("Not connected\n");
exit(1);
}

modbus_close(&mb_param);

}


My bitbake recipe is as follows:

DESCRIPTION = "modbuscomm"
SECTION = "examples"
LICENSE = "GPL"
PR = "r12"

SRC_URI = "file://mymodbuscomm.c \
file://modbus.c \
file://modbus.h \
file://modbus-data.c \
file://modbus-rtu.c \
file://modbus-rtu.h \
file://modbus-tcp.c \
file://modbus-tcp.h"

S = "${WORKDIR}"

do_compile() {
${CC} ${CFLAGS} ${LDFLAGS} mymodbuscomm.c -o mymodbuscomm
${CC} ${CFLAGS} ${LDFLAGS} modbus.c -o modbus
${CC} ${CFLAGS} ${LDFLAGS} modbus-data.c -o modbus-data
${CC} ${CFLAGS} ${LDFLAGS} modbus-rtu.c -o modbus-rtu
${CC} ${CFLAGS} ${LDFLAGS} modbus-tcp.c -o modbus-tcp

}

do_install() {
install -d ${D}${bindir}
install -m 0755 mymodbuscomm ${D}${bindir}
install -m 0755 modbus ${D}${bindir}
install -m 0755 modbus-data ${D}${bindir}
install -m 0755 modbus-rtu ${D}${bindir}
install -m 0755 modbus-tcp ${D}${bindir}
}


I am faced with these errors when I bitbake my application:

Log data follows:
| mymodbuscomm.c: In function 'main':
| mymodbuscomm.c:11: error: 'modbus_param_t' undeclared (first use in this
function)
| mymodbuscomm.c:11: error: (Each undeclared identifier is reported only
once
| mymodbuscomm.c:11: error: for each function it appears in.)
| mymodbuscomm.c:11: error: expected ';' before 'mb_param'
| mymodbuscomm.c:14: error: 'mb_param' undeclared (first use in this
function)
| ERROR: Function do_compile failed


I would very much appreciate it if you could let me know if there is
something wrong with my bitbake recipe or suggest any changes to the recipe.
Thank you and have a great day.

                              Best Regards,
                               JM



More information about the Openembedded-devel mailing list