Sunday 24 June 2012

How to parse the responce with strtok()methd

strtok()

 #include <string.h> 


method prototype :
 
char *strtok( char *str1, const char *str2 );
Description:
The strtok() function returns a pointer to the next "token" in str1, where str2 contains the delimiters that determine the token. strtok() returns NULL if no token is found. In order to convert a string to tokens, the first call to strtok() should have str1 point to the string to be tokenized. All calls after this should have str1 be NULL.
Example:
char str[] = "this  # is  # our #  country";
char delims[] = "#";
char *result = NULL;
result = strtok( str, delims );
while( result != NULL ) {
    printf( "result is \"%s\"\n", result );
    result = strtok( NULL, delims );
}

OUTPUT:
  result is "this "
  result is " is  "
  result is " our "
  result is " country"

Thursday 7 June 2012

How to convert bmp images to hex string

To print image in telium application,do these things...

1-When you will install telium package ..
2-you get a directary name -Bmp convertor

Ptah: 
\SDK30\TDS 6.2.1\tools\Bmp convertor \ConvertBmp


3-Use this tool to convert your image..
Note: Image size should be proper given in telium manual .

link..
http://devraj-it.blogspot.in/2012/06/how-to-send-http-request.html

Wednesday 6 June 2012

How to send HTTP request


#define __INFINITE__ 0x00FFFFFF
#define __20_SECONDS__ 2000
#define __100_MSECONDS__ 10
static int PerformTestTCP_HTTP( char *szHostname, int nPort )
{
int nHandle = 0;
int nResult = 0;
int nReceived = 0;
int nTotalReceived = 0;
unsigned char pucData[64];
//
// Connect to IP Test server.
//
nResult = tcp_connect_to_server( szHostname, nPort, __20_SECONDS__ );
if( nResult >= 0 )
{
nHandle = nResult;
//
// Send HTTP request.
//
while(( nResult = tcp_send_to_server( nHandle,
"GET / HTTP/1.0\r\n\r\n", 18,
__INFINITE__ ))
== ERROR_TIMEOUT )
{
ttestall( 0, __100_MSECONDS__ );
}
if( nResult == 18 )
{
//
// HTTP request sent.
// Infinite Wait (the HTTP disconnection will be performed
// by the remote server.
//
while(( nResult = tcp_recv_from_server( nHandle,
pucData, 64,
__20_SECONDS__ )) > 0 )
{
nReceived = nResult;
nTotalReceived += nReceived;
}
}
// Disconnect and release the allocated handle.
tcp_disconnect_from_server( nHandle );
}
else
{
// Error during connection.
}
return nResult;

Saturday 2 June 2012

How to use a variable in multiple/different source files?

How-to:
To define a global variable or function; you need to do the following:
1. create a header file with the declaration of variable or function.
Ex:
Common.h
#ifndef _COMMON_H_
#define _COMMON_H_
extern int i;
extern int n;
extern unsigned char Array[];
extern void func1();
extern int func2();
#endif
*** Note: The keyword extern is optional in function declarations
2. create a source file with the definition of variable or function.
Common.c
#include "common.h"
int i;      // Define i and initialize
int n;      // Define n and initialize
unsigned char Array[6] = {1,2,3,4,5,6};   // Define Array and initialize
// Define func1 and initialize
void func1(void)
{
    printf("This is ... function 1 \n");
}
// Define func2 and initialize
int func2(void)
{
    printf("This is ... function 2 \n");
    return 0;
}
*** Note: The declaration source file should include (#include) the definition header file.
3. Main program
#include <stdio.h>              // Include general I/O library
#include "common.h"             // Include defined variables and functions
void func3(void);               // Define Local function
void func4(void);               // Define Local function
int main(void)                  // Main Program
{
    printf("i = %d \n", i);     // Print out initial value of i
    printf("n = %d \n", n);     // Print out initial value of n
    i = 8;                      // Set a new value for i
    printf("i = %d \n", i);     // Print out the new value of i
    n = 4;                      // Set a new value for n
    printf("n = %d \n", n);     // Print out the new value of n
    func1();                    // Call global function = function 1 
    func2();                    // Call global function = function 2
    for(i=0; i<6; i++)          // Print out global Array
        printf("%d", Array[i]);
    // Print out blank lines
    printf("\n");
    printf("\n");
    func3();                   // Call local function = function 3
    // Print out blank lines
    printf("\n");
    printf("\n");
    func4();                   // Call local function = function 4
    return 0;                  // End main program
 }
// Definition of local function 3
void func3(void)
{
     printf("This is ... Function 3 \n");
     printf("Please, Enter a new value for variable i = ");
     scanf("%d", &i);
     printf("The new value for variable i = %d \n", i);
}
// Definition of local function 4
void func4(void)
{
     printf("This is ... Function 4 \n");
     for(i=0; i<6; i++)
     {
          printf("Please, Enter a new value for variable Array[%d] = ", i);
          scanf("%d", &Array[i]);
     }
     for(i=0; i<6; i++)
        printf("a new value for variable Array[%d] = %d \n", i, Array[i]);
}
*** Note: Need to include (#include) the definition header file wherever the global variables and functions  are needed in the program code.

 See More http://teliumapplication.blogspot.in/

Friday 1 June 2012

How to use Graphical interface in telium device


There is only one graphic context in EFT 930G that corresponds to the biggest window size (160 * 128 pixels).

1-There is no blinking process possible.Means ,donot use blink(on) methods.
2-Use of original printf, fprintf, gotoxy, wherex, wherey, cursor routines are not recommended as they are not linked to the graphic context.

3-In order to optimise the time to display, it is recommended to work on the full screen bits array and just paint at the end.
4-In other words, strings and bit maps can be inserted at different x and y position to build the full screen and when everything is done, paint routine can then be called.
5-A DOS tool will be provided that allows converting BMP file to defdisplaypattern bit map in order to quickly define some images
.Example:
// Put a text at 14,10 location
FontSize=_SMALL_;
CreateGraphics(FontSize);
_DrawString("TEXTE",14,10,_OFF_);
PaintGraphics();
// then clear this text
_SetArea (14,10,14+StringWidth("TEXTE"),14+FontSize,_OFF_);
PaintGraphics();

See more: http://teliumapplication.blogspot.in/