Looking for Informix4GL by Example header file 'fgicfunc.h' - c

I am working through the Informix4GL by Example cookbook. Exercise 13 deals with creating external callable modules written in C. The example code contains this line:
#include "fgicfunc.h"
But I cannot find this file or a description of its contents. It is supposed to be related to the Informix database software product but I do not have this installed. Does anyone here have that file; and if you do then can you provide me the contents?

Despite the copyright notice, etc, this is published when you install the I4GL p-code compiler.
/**************************************************************************/
/* */
/* Licensed Materials - Property of IBM */
/* */
/* "Restricted Materials of IBM" */
/* */
/* IBM Informix 4GL */
/* (c) Copyright IBM Corporation 2010 All rights reserved. */
/* */
/**************************************************************************/
/***************************************************************************
*
* INFORMIX SOFTWARE, INC.
*
* PROPRIETARY DATA
*
* THIS DOCUMENT CONTAINS TRADE SECRET DATA WHICH IS THE PROPERTY OF
* INFORMIX SOFTWARE, INC. THIS DOCUMENT IS SUBMITTED TO RECIPIENT IN
* CONFIDENCE. INFORMATION CONTAINED HEREIN MAY NOT BE USED, COPIED OR
* DISCLOSED IN WHOLE OR IN PART EXCEPT AS PERMITTED BY WRITTEN AGREEMENT
* SIGNED BY AN OFFICER OF INFORMIX SOFTWARE, INC.
*
* THIS MATERIAL IS ALSO COPYRIGHTED AS AN UNPUBLISHED WORK UNDER
* SECTIONS 104 AND 408 OF TITLE 17 OF THE UNITED STATES CODE.
* UNAUTHORIZED USE, COPYING OR OTHER REPRODUCTION IS PROHIBITED BY LAW.
*
*
* Title: fgicfunc.h
* Description: 4GL C function header file
*
***************************************************************************
*/
#ifndef IBM_I4GL_FGICFUNC_H
#define IBM_I4GL_FGICFUNC_H
typedef struct
{
char *cf_name; /* name of function */
int (*cf_ptr)(int); /* pointer to the function */
short cf_nargs; /* number of arguments, < 0 means variable */
} cfunc_t;
#endif /* IBM_I4GL_FGICFUNC_H */
We can discuss the erratic boxing comments another time.

Related

Doxygen filter script breaks auto-link generation

I’m trying to fix some proprietary compiler directives by using a filter. I discovered that if I pass a file through a filter, the file documentation is generated correctly, but auto-linking seems broken!
I came up with a very simple example. My filter is implemented in Python and it just opens the file and prints every single line, it doesn’t change anything. I confirmed this by comparing the filter’s input and output (by redirection) with a diff and there are no differences at all.
I redirected the filter’s output to a file called filtered_c.h. If I include this file as a source file, I get auto-link to work. If I pass the original header file through the filter, auto-linking is broken and I get a warning
latex_double.md:7: warning: unable to resolve reference to `some_c_function' for \ref command
If I comment out the FILTER_PATTERNS line in the Doxyfile, auto-linking works.
This is really an issue for me, as I’m also supporting parsing assembly files through a filter script and I see the same behavior there: the file documentation is perfect, but no auto-linking.
I'm using Doxygen 1.8.15 in windows 10.
Any thoughts are very welcome! Thanks!
Doxyfile:
# General options
PROJECT_NAME = "Double table headers in LaTeX"
INPUT = doc/latex_double.md
INPUT += include/regular_c.h
#INPUT += filtered_c.h
#You should not need to change the rest of the file
OUTPUT_DIRECTORY = output_doc
GENERATE_HTML = YES
GENERATE_TREEVIEW = YES
GENERATE_LATEX = YES
OPTIMIZE_OUTPUT_FOR_C = YES
FILTER_PATTERNS += *.h="c:\Python27\python filter\dummy_filter.py"
Filter Script:
from __future__ import print_function
import sys
if len(sys.argv) != 2:
sys.exit(1)
def extract_globals(filename):
with open(filename, 'r') as infile:
for line in infile:
print(line, end='')
extract_globals(sys.argv[1])
Markdown source:
# Chapter Title {#chapter_title}
Some text here
# Introduction {#chapter_intro}
Loren Ipsum #ref some_c_function
regular_c.h
/**
* #file regular_c.h
* #brief This is a simple C header file with some examples.
*/
#ifndef REGULAR_C_H_
#define REGULAR_C_H_
/* ----------------------------------------------------------------------------
* If building with a C++ compiler, make all of the definitions in this header
* have a C binding.
* ------------------------------------------------------------------------- */
#ifdef __cplusplus
extern "C"
{
#endif /* ifdef __cplusplus */
/* ----------------------------------------------------------------------------
* Include files
* --------------------------------------------------------------------------*/
/* ----------------------------------------------------------------------------
* Defines
* --------------------------------------------------------------------------*/
/* ----------------------------------------------------------------------------
* Global variables and types
* --------------------------------------------------------------------------*/
/**
* This enumeration has the return codes for the #ref some_c_function function.
*/
typedef enum __SOME_C_FUNCTION_RETURN {
SOME_C_FUNCTION_RETURN_everthing_ok = 0, ///< Nothing to see here
SOME_C_FUNCTION_RETURN_some_weird_error, ///< This is not the error you're looking for
SOME_C_FUNCTION_RETURN_some_very_bad_error, ///< This is not the error we are looking for
SOME_C_FUNCTION_RETURN_life_is_sad_just_cope ///< Move along
} SOME_C_FUNCTION_RETURN;
/* ----------------------------------------------------------------------------
* Function prototype definitions
* --------------------------------------------------------------------------*/
/**
* #brief Some C function that is here just as an example.
*
* This function doesn't actually do anything useful.
*
* #param[in] v We do something with this value.
* #param[out] ptr Some value will be written here.
*
* #return Returns a value that depends on what happened:
* - #ref SOME_C_FUNCTION_RETURN_everthing_ok
* Uh, everything is under control. Situation normal.
* - #ref SOME_C_FUNCTION_RETURN_some_weird_error
* Uh, had a slight weapons malfunction.
* - #ref SOME_C_FUNCTION_RETURN_some_very_bad_error
* We had a reactor leak here now. Give us a few minutes to lock it down.
* Large leak... very dangerous.
* - #ref SOME_C_FUNCTION_RETURN_life_is_sad_just_cope
* Who is this?? What's your operating number?
*
*/
int some_c_function(uint32_t v, void* ptr);
/* ----------------------------------------------------------------------------
* Close the 'extern "C"' block
* ------------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif /* ifdef __cplusplus */
#endif /* REGULAR_C_H_ */
filtered_c.h
/**
* #file filtered_c.h
* #brief This is a simple C header file with some examples.
*/
#ifndef REGULAR_C_H_
#define REGULAR_C_H_
/* ----------------------------------------------------------------------------
* If building with a C++ compiler, make all of the definitions in this header
* have a C binding.
* ------------------------------------------------------------------------- */
#ifdef __cplusplus
extern "C"
{
#endif /* ifdef __cplusplus */
/* ----------------------------------------------------------------------------
* Include files
* --------------------------------------------------------------------------*/
/* ----------------------------------------------------------------------------
* Defines
* --------------------------------------------------------------------------*/
/* ----------------------------------------------------------------------------
* Global variables and types
* --------------------------------------------------------------------------*/
/**
* This enumeration has the return codes for the #ref some_c_function function.
*/
typedef enum __SOME_C_FUNCTION_RETURN {
SOME_C_FUNCTION_RETURN_everthing_ok = 0, ///< Nothing to see here
SOME_C_FUNCTION_RETURN_some_weird_error, ///< This is not the error you're looking for
SOME_C_FUNCTION_RETURN_some_very_bad_error, ///< This is not the error we are looking for
SOME_C_FUNCTION_RETURN_life_is_sad_just_cope ///< Move along
} SOME_C_FUNCTION_RETURN;
/* ----------------------------------------------------------------------------
* Function prototype definitions
* --------------------------------------------------------------------------*/
/**
* #brief Some C function that is here just as an example.
*
* This function doesn't actually do anything useful.
*
* #param[in] v We do something with this value.
* #param[out] ptr Some value will be written here.
*
* #return Returns a value that depends on what happened:
* - #ref SOME_C_FUNCTION_RETURN_everthing_ok
* Uh, everything is under control. Situation normal.
* - #ref SOME_C_FUNCTION_RETURN_some_weird_error
* Uh, had a slight weapons malfunction.
* - #ref SOME_C_FUNCTION_RETURN_some_very_bad_error
* We had a reactor leak here now. Give us a few minutes to lock it down.
* Large leak... very dangerous.
* - #ref SOME_C_FUNCTION_RETURN_life_is_sad_just_cope
* Who is this?? What's your operating number?
*
*/
int some_c_function(uint32_t v, void* ptr);
/* ----------------------------------------------------------------------------
* Close the 'extern "C"' block
* ------------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif /* ifdef __cplusplus */
#endif /* REGULAR_C_H_ */

Multiple SPI masters active at once

I'm facing the problem when trying to get 2 SPI masters working at same time. They both have different pins(mosi, miso, sck, ss) and one is used by SD-Card and another one accelerometer. My device is nRF52832 and I have been trying to use SPI drivers from nRF52 SDK 15.2.0.
I'm not sure if they can be initialized and in use same time, but its feeling quite wrong if the program needs to init and uninit another spi instance whenever it needs to communicate with another one.
Seems that whenever one instance gets initialized the second one does not work correctly. The program does not give any error. This is my first touch to embedded systems and because of that, my skill level is the novice. I really would appreciate all the help.
/**
* Copyright (c) 2016 - 2018, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/** #file
* #defgroup fatfs_example_main main.c
* #{
* #ingroup fatfs_example
* #brief FATFS Example Application main file.
*
* This file contains the source code for a sample application using FAT filesystem and SD card library.
*
*/
#include "nrf.h"
#include "bsp.h"
#include "ff.h"
#include "diskio_blkdev.h"
#include "nrf_block_dev_sdc.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#include "nrf_gpio.h"
#include "nrf_delay.h"
#include "nrf_drv_spi.h"
#define FILE_NAME "NORDIC.TXT"
#define TEST_STRING "SD card example."
#define SDC_SCK_PIN 16 ///< SDC serial clock (SCK) pin.
#define SDC_MOSI_PIN 17 ///< SDC serial data in (DI) pin.
#define SDC_MISO_PIN 18 ///< SDC serial data out (DO) pin.
#define SDC_CS_PIN 11 ///< SDC chip select (CS) pin.
#define SDC2_SCK_PIN 5
#define SDC2_MOSI_PIN 4
#define SDC2_MISO_PIN 3
#define SDC2_CS_PIN 12
#define SPI_AC_INSTANCE 1
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_AC_INSTANCE);
/**
* #brief SDC block device definition
* */
NRF_BLOCK_DEV_SDC_DEFINE(
m_block_dev_sdc,
NRF_BLOCK_DEV_SDC_CONFIG(
SDC_SECTOR_SIZE,
APP_SDCARD_CONFIG(SDC_MOSI_PIN, SDC_MISO_PIN, SDC_SCK_PIN, SDC_CS_PIN)
),
NFR_BLOCK_DEV_INFO_CONFIG("Nordic", "SDC", "1.00")
);
/**
* #brief Function for demonstrating FAFTS usage.
*/
static void fatfs_example()
{
static FATFS fs;
static DIR dir;
static FILINFO fno;
static FIL file;
uint32_t bytes_written;
FRESULT ff_result;
DSTATUS disk_state = STA_NOINIT;
// Initialize FATFS disk I/O interface by providing the block device.
static diskio_blkdev_t drives[] =
{
DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc, block_dev), NULL)
};
diskio_blockdev_register(drives, ARRAY_SIZE(drives));
NRF_LOG_INFO("Initializing disk 0 (SDC)...");
for (uint32_t retries = 3; retries && disk_state; --retries)
{
disk_state = disk_initialize(0);
}
if (disk_state)
{
NRF_LOG_INFO("Disk initialization failed.");
return;
}
uint32_t blocks_per_mb = (1024uL * 1024uL) / m_block_dev_sdc.block_dev.p_ops->geometry(&m_block_dev_sdc.block_dev)->blk_size;
uint32_t capacity = m_block_dev_sdc.block_dev.p_ops->geometry(&m_block_dev_sdc.block_dev)->blk_count / blocks_per_mb;
NRF_LOG_INFO("Capacity: %d MB", capacity);
NRF_LOG_INFO("Mounting volume...");
ff_result = f_mount(&fs, "", 1);
if (ff_result)
{
NRF_LOG_INFO("Mount failed.");
return;
}
NRF_LOG_INFO("\r\n Listing directory: /");
ff_result = f_opendir(&dir, "/");
if (ff_result)
{
NRF_LOG_INFO("Directory listing failed!");
return;
}
do
{
ff_result = f_readdir(&dir, &fno);
if (ff_result != FR_OK)
{
NRF_LOG_INFO("Directory read failed.");
return;
}
if (fno.fname[0])
{
if (fno.fattrib & AM_DIR)
{
NRF_LOG_RAW_INFO(" <DIR> %s",(uint32_t)fno.fname);
}
else
{
NRF_LOG_RAW_INFO("%9lu %s", fno.fsize, (uint32_t)fno.fname);
}
}
}
while (fno.fname[0]);
NRF_LOG_RAW_INFO("");
NRF_LOG_INFO("Writing to file " FILE_NAME "...");
ff_result = f_open(&file, FILE_NAME, FA_READ | FA_WRITE | FA_OPEN_APPEND);
if (ff_result != FR_OK)
{
NRF_LOG_INFO("Unable to open or create file: " FILE_NAME ".");
return;
}
ff_result = f_write(&file, TEST_STRING, sizeof(TEST_STRING) - 1, (UINT *) &bytes_written);
if (ff_result != FR_OK)
{
NRF_LOG_INFO("Write failed\r\n.");
}
else
{
NRF_LOG_INFO("%d bytes written.", bytes_written);
}
(void) f_close(&file);
return;
}
static uint8_t tx_buf[3];
static uint8_t rx_buf[10]; /**< RX buffer. */
uint8_t accReadByte(uint8_t RegisterAddress)
{
tx_buf[0] = 0x7F & RegisterAddress;
tx_buf[1] = 0x80 & RegisterAddress;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, tx_buf, 2, rx_buf, 1+2));
return rx_buf[2];
}
void initAcc()
{
//nrf_gpio_set_cfg_output(SDC2_CS_PIN);
nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.ss_pin = SDC2_CS_PIN;
spi_config.miso_pin = SDC2_MISO_PIN;
spi_config.mosi_pin = SDC2_MOSI_PIN;
spi_config.sck_pin = SDC2_SCK_PIN;
spi_config.frequency = NRF_SPI_FREQ_250K;
APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, NULL, NULL));
}
/**
* #brief Function for main application entry.
*/
int main(void)
{
bsp_board_init(BSP_INIT_LEDS);
APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
NRF_LOG_DEFAULT_BACKENDS_INIT();
NRF_LOG_INFO("FATFS example started.");
fatfs_example();
initAcc();
if ( accReadByte(0x0D) == 0x6A )
{
NRF_LOG_INFO("Got right whoami!");
}
while (true)
{
__WFE();
}
}
/** #} */
Problem solved. SD-Card and the accelerometer both have different serial bus in default. When initialized another one first, second one failed in bus initialization and that caused nRF52832 not to get the right answer.

How to log to /var/log/mail.log using rsyslogd?

I am currently playing around with logging under Linux. I have made the following very simple test application (in plain C):
#include <syslog.h>
int main(int argc, char **argv)
{
openlog("mytest", (LOG_PID | LOG_NDELAY), LOG_MAIL);
syslog(LOG_MAKEPRI(LOG_MAIL, LOG_ERR), "Test");
return(0);
}
This "application" compiles, and when I execute it, it generates an entry in /var/log/syslog, but no entry in /var/log/mail.log and no entry in /var/log/mail.err.
Could somebody please explain why?
I am using rsyslogd on the test machine; this is the configuration from /etc/rsyslog.conf (please note that /etc/rsyslog.d is just empty, and that I have stripped out all comments and lines which clearly don't have anything to do with the problem):
:msg,startswith, " fetching user_deny" ~
:msg,startswith, " seen_db: user " ~
auth,authpriv.* /var/log/auth.log
*.*;auth,authpriv.none -/var/log/syslog
daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
lpr.* -/var/log/lpr.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log
mail.info -/var/log/mail.info
mail.warn -/var/log/mail.warn
mail.err /var/log/mail.err
*.=debug;\
auth,authpriv.none;\
news.none;mail.none -/var/log/debug
*.=info;*.=notice;*.=warn;\
auth,authpriv.none;\
cron,daemon.none;\
mail,news.none -/var/log/messages
*.emerg :omusrmsg:*
daemon.*;mail.*;\
news.err;\
*.=debug;*.=info;\
*.=notice;*.=warn |/dev/xconsole
As far as I have understood from reading man rsyslog.conf, that configuration should make rsyslogd write messages for LOG_MAIL with priority LOG_ERR to /var/log/mail.err. I am somewhat mistrustful regarding the lines where the file path has a - prepended, though. I don't know what this means because I could not find any hint in the manual.
So what is going wrong?
I hate answering my own question, but I think I have found a bug either in the documentation or in the source of glibc, and I'd like to have it documented for future visitors of this question.
From https://www.gnu.org/software/libc/manual/html_node/syslog_003b-vsyslog.html#syslog_003b-vsyslog (as per the time of this writing):
syslog submits the message with the facility and priority indicated by
facility_priority. The macro LOG_MAKEPRI generates a facility/priority
from a facility and a priority, as in the following example:
LOG_MAKEPRI(LOG_USER, LOG_WARNING)
Now look at some code from syslog.h as it resides on my test machine (Debian wheezy, up-to-date, no custom patches, non-relevant parts stripped out):
/*
* priorities/facilities are encoded into a single 32-bit quantity, where the
* bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
* (0-big number). Both the priorities and the facilities map roughly
* one-to-one to strings in the syslogd(8) source code. This mapping is
* included in this file.
*
* priorities (these are ordered)
*/
#define LOG_EMERG 0 /* system is unusable */
#define LOG_ALERT 1 /* action must be taken immediately */
#define LOG_CRIT 2 /* critical conditions */
#define LOG_ERR 3 /* error conditions */
#define LOG_WARNING 4 /* warning conditions */
#define LOG_NOTICE 5 /* normal but significant condition */
#define LOG_INFO 6 /* informational */
#define LOG_DEBUG 7 /* debug-level messages */
#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
/* facility codes */
#define LOG_KERN (0<<3) /* kernel messages */
#define LOG_USER (1<<3) /* random user-level messages */
#define LOG_MAIL (2<<3) /* mail system */
#define LOG_DAEMON (3<<3) /* system daemons */
#define LOG_AUTH (4<<3) /* security/authorization messages */
#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
#define LOG_LPR (6<<3) /* line printer subsystem */
#define LOG_NEWS (7<<3) /* network news subsystem */
#define LOG_UUCP (8<<3) /* UUCP subsystem */
#define LOG_CRON (9<<3) /* clock daemon */
#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
#define LOG_FTP (11<<3) /* ftp daemon */
/* other codes through 15 reserved for system use */
#define LOG_LOCAL0 (16<<3) /* reserved for local use */
#define LOG_LOCAL1 (17<<3) /* reserved for local use */
#define LOG_LOCAL2 (18<<3) /* reserved for local use */
#define LOG_LOCAL3 (19<<3) /* reserved for local use */
#define LOG_LOCAL4 (20<<3) /* reserved for local use */
#define LOG_LOCAL5 (21<<3) /* reserved for local use */
#define LOG_LOCAL6 (22<<3) /* reserved for local use */
#define LOG_LOCAL7 (23<<3) /* reserved for local use */
We are obviously having multiple problems here.
The comment at the top: If I have 3 bottom bits, then I have 29 top bits (and not 28). But this is a minor problem.
The facility codes are already defined as shifted-to-left by three bits. Using the macro LOG_MAKEPRI (as recommended by the manual page linked above) obviously shifts them to the left by three bits a second time, which clearly is wrong.
SOLUTION
The solution is simple: Don't use that macro; instead, just OR the facility code and the priority code. I have tried that, and it worked. Error messages from my test programs are now logged as expected, according to the configuration of rsyslogd in /etc/rsyslog.conf.
I am quite surprised about that very obvious bug in syslog.h ...

Read excel file in C using libxls

I am trying to create an application that reads an excel file using libxls.
I've already downloaded libxls but I do not know how to use it.
Can someone please show me a minimum program to read from a XLS file
If you mean libxls:
There are tests inside the source archive which can be used as sample code.
Here's the content of libxls-1.4.0/test/test2.c:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of libxls -- A multiplatform, C/C++ library
* for parsing Excel(TM) files.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY David Hoerl ''AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David Hoerl OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 2004 Komarov Valery
* Copyright 2006 Christophe Leitienne
* Copyright 2008-2012 David Hoerl
*
*/
// THIS FILE LETS YOU QUICKLY FEED A .xls FILE FOR PARSING
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "libxls/xls.h"
int main(int argc, char *argv[])
{
xlsWorkBook* pWB;
xlsWorkSheet* pWS;
unsigned int i;
if(argc != 2) {
printf("Need file arg\n");
exit(0);
}
struct st_row_data* row;
WORD t,tt;
pWB=xls_open(argv[1],"UTF-8");
if (pWB!=NULL)
{
for (i=0;i<pWB->sheets.count;i++)
printf("Sheet N%i (%s) pos %i\n",i,pWB->sheets.sheet[i].name,pWB->sheets.sheet[i].filepos);
pWS=xls_getWorkSheet(pWB,0);
xls_parseWorkSheet(pWS);
printf("pWS->rows.lastrow %d\n", pWS->rows.lastrow);
for (t=0;t<=pWS->rows.lastrow;t++)
{
printf("DO IT");
row=&pWS->rows.row[t];
xls_showROW(row);
for (tt=0;tt<=pWS->rows.lastcol;tt++)
{
xls_showCell(&row->cells.cell[tt]);
}
}
printf("Count of rows: %i\n",pWS->rows.lastrow);
printf("Max col: %i\n",pWS->rows.lastcol);
printf("Count of sheets: %i\n",pWB->sheets.count);
xls_showBookInfo(pWB);
} else {
printf("pWB == NULL\n");
}
return 0;
}
If you mean libxl:
Below you'll find a data reading example written in C from http://www.libxl.com/.
Furthermore they provide documentation and more examples on their homepage.
BookHandle book = xlCreateBook();
if(book)
{
if(xlBookLoad(book, L"example.xls"))
{
SheetHandle sheet = xlBookGetSheet(book, 0);
if(sheet)
{
double d;
const wchar_t* s = xlSheetReadStr(sheet, 2, 1, NULL);
if(s) wprintf(L"%s\n", s);
d = xlSheetReadNum(sheet, 3, 1, NULL);
printf("%g\n", d);
}
}
xlBookRelease(book);
}

lpc4370 LPCXPRESSO Programming

I have some programming knowledge with regards to Arduino and Msp430 (using Embedded C). But, I am unable to understand where to start learning when it comes to LPC4370. I have a requirement for programming the above mentioned chip but I don't find any material that explains the various function that can be used in programming the LPC4370. LPCopen has a lot of codes but I can find out the utility of various functions used. If someone could give a hint on where to start, it would be really helpful.
Thanks in advance.
I have not worked with LPC 4370 but I have experience with lpc2148.
Few things I would suggest you :
Download LPCEXPRESSO IDE from here
Download LPCXPRESSO IDE GUIDE from here
Learn how to create projects . How to load into hardware.
Then learn to create simple task from rtos like FreeRTOS
Read this ST manual for various RTOS function
Here is sample program of creating simple task. you can refer and similarly you can read following exercises and proceed.
/*
FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
***NOTE*** The exception to the GPL is included to allow you to distribute
a combined work that includes FreeRTOS without being obliged to provide the
source code for proprietary components outside of the FreeRTOS kernel.
FreeRTOS 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 and the FreeRTOS license exception along with FreeRTOS; if not it
can be viewed here: http://www.freertos.org/a00114.html and also obtained
by writing to Richard Barry, contact details for whom are available on the
FreeRTOS WEB site.
1 tab == 4 spaces!
http://www.FreeRTOS.org - Documentation, latest information, license and
contact details.
http://www.SafeRTOS.com - A version that is certified for use in safety
critical systems.
http://www.OpenRTOS.com - Commercial support, development, porting,
licensing and training services.
*/
#include "FreeRTOS.h"
#include "task.h"
/* Demo includes. */
#include "basic_io.h"
/* Used as a loop counter to create a very crude delay. */
#define mainDELAY_LOOP_COUNT ( 0xfffff )
/* The task functions. */
void vTask1( void *pvParameters );
void vTask2( void *pvParameters );
int main( void )
{
/* Init the semi-hosting. */
printf( "\n" );
/* Create one of the two tasks. */
xTaskCreate( vTask1, /* Pointer to the function that implements the task. */
"Task 1", /* Text name for the task. This is to facilitate debugging only. */
240, /* Stack depth in words. */
NULL, /* We are not using the task parameter. */
1, /* This task will run at priority 1. */
NULL ); /* We are not using the task handle. */
/* Create the other task in exactly the same way. */
xTaskCreate( vTask2, "Task 2", 240, NULL, 1, NULL );
/* Start the scheduler so our tasks start executing. */
//
vTaskStartScheduler();
for( ;; );
return 0;
}
/*-----------------------------------------------------------*/
void vTask1( void *pvParameters )
{
const char *pcTaskName = "Task 1 is running\n";
volatile unsigned long ul;
/* As per most tasks, this task is implemented in an infinite loop. */
for( ;; )
{
/* Print out the name of this task. */
vPrintString( pcTaskName );
/* Delay for a period. */
for( ul = 0; ul < mainDELAY_LOOP_COUNT; ul++ )
{
/* This loop is just a very crude delay implementation. There is
nothing to do in here. Later exercises will replace this crude
loop with a proper delay/sleep function. */
}
}
//??????delete your task
}
void vTask2( void *pvParameters )
{
const char *pcTaskName = "Task 2 is running\n";
volatile unsigned long ul;
/* As per most tasks, this task is implemented in an infinite loop. */
for( ;; )
{
/* Print out the name of this task. */
vPrintString( pcTaskName );
/* Delay for a period. */
for( ul = 0; ul < mainDELAY_LOOP_COUNT; ul++ )
{
/* This loop is just a very crude delay implementation. There is
nothing to do in here. Later exercises will replace this crude
loop with a proper delay/sleep function. */
}
}
}
/*-----------------------------------------------------------*/
void vApplicationMallocFailedHook( void )
{
/* This function will only be called if an API call to create a task, queue
or semaphore fails because there is too little heap RAM remaining. */
for( ;; );
}
/*-----------------------------------------------------------*/
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )
{
/* This function will only be called if a task overflows its stack. Note
that stack overflow checking does slow down the context switch
implementation. */
for( ;; );
}
/*-----------------------------------------------------------*/
void vApplicationIdleHook( void )
{
/* This example does not use the idle hook to perform any processing. */
}
/*-----------------------------------------------------------*/
void vApplicationTickHook( void )
{
/* This example does not use the tick hook to perform any processing. */
}
What type of example you can practice ? it can be found here

Resources