need coding to solve my project

Now im doing a project whereby i need to send the data of the temperature to the gsm modem.However, i dunno how to create a code to link them up..can any kind soul help?? will appreciate it alot.... thanks....
Post the code you have now, or designs so we have some idea of what you've done and where you are stuck.

http://www.cplusplus.com/forum/beginner/1/
here is the code i have. but i duno how to solve it. i split it into 2 parts.. thanks alot...


#include <windows.h>
#include <conio.h>
#include <stdio.h>

/* Definitions of drdaq driver routines */
#include "drdaqw.h"

#define BUFFER_SIZE 1024
#define TRUE 1
#define FALSE 0
#define MAX_CHANNELS_AT_ONCE 2 // You can change this up to 11 (DRDAQ)

long times [BUFFER_SIZE];
short values [BUFFER_SIZE * MAX_CHANNELS_AT_ONCE];
int port;


/****************************************************************************
*
* Collect_block_immediate
* this function demonstrates how to collect a single block of data
* from the unit (start collecting immediately)
*
****************************************************************************/

void collect_block_immediate (void)
{
int i;
long actual;
static short channels [] = {1, 3};

printf ("Collect block immediate...\n");
printf ("Press a key to start\n");
getch ();

/* Trigger disabled
*/
drdaq_set_trigger (FALSE, FALSE, 0, 0, FALSE, 0, 0);

/* Collect data for 50000us
* BUFFER_SIZE points
* Channels 1 and 3 only
*/
actual = drdaq_set_interval (50000, BUFFER_SIZE, channels, 2);

/* If the ADC cannot go as fast as you require,
* it will have returned and actual time > 50000.
* If you would prefer to take fewer samples to get exactly 50000 us,
* you can use the following formula:
*
* no_of_samples = BUFFER_SIZE * 50000 / actual;
*/

/* Start it collecting,
* then wait for completion
*/
drdaq_run (BUFFER_SIZE, BM_SINGLE);
while (!drdaq_ready ())
{
Sleep (100);
}

/* Should be done now...
* get the times (in microsecondss)
* and the values (in ADC counts)
*/
drdaq_get_times_and_values (times, values, BUFFER_SIZE);

/* Print out the first 10 readings,
* converting the readings to mV if required
*/
printf ("First 10 readings\n");
printf ("Time\tCh1\tCh3\n");
for (i = 0; i < 10; i++)
{
printf ("%ld\t%d\t%d\n", times [i], values [2*i], values [2*i+1]);
}

}

/****************************************************************************
*
* Collect_block_triggered
* this function demonstrates how to collect a single block of data from the
* unit, when a trigger event occurs.
*
****************************************************************************/

void collect_block_triggered (void)
{
int i;
long actual;
int trigger_sample;
static short channels [] = {1};

printf ("Collect block triggered...\n");
printf ("Collects when value rises past 500mV\n");
printf (" or after ten seconds\n");
printf ("Press a key to start...\n");
getch ();

/* Trigger enabled
* Auto-trigger after 10000ms
* Channel 1 (but it doesn't have to be the same as sample channel)
* Rising edge
* Threshold = 500
* 10% pre-trigger (negative is pre-, positive is post-)
*/
drdaq_set_trigger (TRUE, TRUE, 10000, 1, FALSE, 500, -10);

/* Here is an alternative trigger command...
* it waits forever for a trigger event (no auto-trigger)
* drdaq_set_trigger (TRUE, FALSE, 0, FALSE, mv_to_adc (500), -10);
*/

/* Collect data for 50000us
* BUFFER_SIZE points
* Channel A
*/
actual = drdaq_set_interval (50000, BUFFER_SIZE, channels, 1);

/* If the ADC cannot go as fast as you require,
* it will have returned and actual time > 50000.
* If you would prefer to take fewer samples to get exactly 50000 us,
* you can use the following formula:
*
* no_of_samples = BUFFER_SIZE * 50000 / actual;
*/

/* Start it collecting,
* then wait for completion
*/
drdaq_run (BUFFER_SIZE, BM_SINGLE);

printf ("Waiting for trigger...");
printf ("Press a key to abort\n");

while ((!drdaq_ready ()) && (!kbhit ()))
{
Sleep (100);
}

if (kbhit ())
{
getch ();
drdaq_stop ();
printf ("data collection aborted\n");
}
else
{
/* Get the times (in microsecondss)
* and the values (in ADC counts)
*/
drdaq_get_times_and_values (times, values, BUFFER_SIZE);

/* Print out the first 10 readings,
* converting the readings to mV if required
*/

printf ("Ten readings around trigger\n");
printf ("Time\tValue\n");
// printf ("(us)\t(%s)\n", adc_units ());

/* This calculation is correct for 10% pre-trigger
*/
trigger_sample = BUFFER_SIZE / 10;

for (i = trigger_sample - 5; i < trigger_sample + 5; i++)
{
printf ("%ld\t%d\n", times [i], values [i]);
}
}
}
part 2:

/****************************************************************************
*
* Collect_windowed_blocks
* this function demonstrates how to use windowed blocks.
*
* Windowing is useful If you are collecting data slowly (say 10 seconds
* per block), but you want to analyse the data every second.
*
* Each call to drdaq_get_times_and_values returns the most recent 10 seconds
* of data.
*
****************************************************************************/

void collect_windowed_blocks (void)
{
int i;
long actual;
static short channels [] = {1};

printf ("Collect windowed block...\n");
printf ("First block appears after 10 seconds,\n");
printf ("Subsequent blocks every second...\n");
printf ("Press a key to start\n");
getch ();

/* You could use triggering for the start of the data,
* but only for the first block...
* We will not use trigger,
*/
drdaq_set_trigger (FALSE, FALSE, 0, 0, FALSE, 0, 0);

/* Collect data for 10 seconds
* BUFFER_SIZE points
*/
actual = drdaq_set_interval (10000000, BUFFER_SIZE, channels, 1);

/* Start it collecting,
* then wait for completion of first block
*/
drdaq_run (BUFFER_SIZE, BM_WINDOW);
printf ("Waiting for first block...\n");


while (!drdaq_ready ())
{
Sleep (100);
}

/* From here on, we can get data whenever we want...
* we will receive the last 10 second's data.
*/
while (!kbhit ())
{
drdaq_get_times_and_values (times, values, BUFFER_SIZE);

/* Print out the first 10 readings
*/
for (i = 0; i < 10; i++)
{
printf ("%ld\t%d\n", times [i], values [i]);
}
printf ("Press any key to stop\n");
/* Wait a second before asking again
*/
Sleep (1000);
}

}

/****************************************************************************
*
* Collect_streaming
* this function demonstrates how to use streaming.
*
* In this mode, you can collect data continuously at high speed.
*
* This example writes data to disk...
* don't leave it running too long or it will fill your disk up!
*
* Each call to drdaq_get_times_and_values returns the readings since the
* last call
*
* The time is in microseconds: it will wrap around at 2^32 (approx 2,000 seconds)
* if you don't need the time, you can just call drdaq_get_values
*
****************************************************************************/

void collect_streaming (void)
{
int i;
int block_no;
long actual;
FILE * fp;
int no_of_values;
static short channels [] = {1};


printf ("Collect streaming...\n");
printf ("Data is written to disk file (test.out)\n");
printf ("Press a key to start\n");
getch ();

/* You could use triggering for the start of the data...
* We will not use trigger,
*/
drdaq_set_trigger (FALSE, TRUE, 1000, 0, FALSE, 80, -10);

/* Collect data at 1000us intervals
* Max BUFFER_SIZE points on each call
* (buffer must be big enought for max time between calls
*/
actual = drdaq_set_interval (BUFFER_SIZE * 1000, BUFFER_SIZE, channels, 1);

/* Start it collecting,
* then wait for trigger event
*/
drdaq_run (BUFFER_SIZE, BM_STREAM);
while (!drdaq_ready ())
{
Sleep (100);
}

/* From here on, we can get data whenever we want...
*/
block_no = 0;
fp = fopen ("test.out", "w");
while (!kbhit ())
{
no_of_values = drdaq_get_times_and_values (times, values, BUFFER_SIZE);
printf ("%d values\n", no_of_values);

if (block_no++ > 20)
{
block_no = 0;
printf ("Press any key to stop\n");
}

/* Print out the first 10 readings
*/
for (i = 0; i < no_of_values; i++)
{
fprintf (fp, "%8ld\t%d\n", times [i], values [i]);
}

/* Wait 100ms before asking again
*/
Sleep (100);
}
fclose (fp);

drdaq_stop ();

getch ();

}

/****************************************************************************
*
* Collect_individual
* this function demonstrates how to take individual readings under
* direct program control.
*
****************************************************************************/

void collect_individual (void)
{
int sample_no;
int c;
char str [40];
short value;
short divider;
short places;

printf ("Collect individual...\n");
printf ("Takes individual readings under program control\n");
printf ("Sample from all channels\n");
printf ("Press a key to start\n");
getch ();

sample_no = 20;
while (!kbhit ())
{

Sleep (100);
if (++sample_no > 20)
{
sample_no = 0;
printf ("Press any key to stop\n");

/* Sensor name for each channel
*/
for (c = 1; c <= 9; c++)
{
drdaq_get_channel_text (str, c, 3);
printf ("%s\t", str);
}
printf ("\n");

/* Units for each channel
*/
for (c = 1; c <= 9; c++)
{
drdaq_get_channel_text (str, c, 4);
printf ("%s\t", str);
}
printf ("\n");
}

/* Read all nine channels
* 10 and 11 are the sensor type resistors for EXT1 and EXT2
*/
for (c = 1; c <= 11; c++)
{
value = drdaq_get_value (c);
if (value == INVALID_DRDAQ_SCALED)
{
printf ("\t");
}
else
{
drdaq_get_channel_info (NULL, NULL, &places, &divider, NULL, c);

printf ("%0.*f\t", places, ((float) (value)) / divider);
}
}
printf ("\n");
}

getch ();

}


/****************************************************************************
*
*
****************************************************************************/

void main (void)
{
char line [80];
int ok;
int i;
char ch;

printf ("drdaq driver example program\n");
printf ("Version 1.0\n\n");

printf ("Select the parallel port\n");
printf ("Use 1 for LPT1,\n"
" 2 for LPT2, etc\n"
" 101 for USB port 1, etc\n");
printf ("Port: ");
scanf ("%d", &port);

printf ("\n\nOpening the device...\n");
ok = drdaq_open_unit (port);
if (!ok)
{
printf ("Unable to open device\n");
drdaq_get_unit_info (line, sizeof (line), 0, port);
printf ("%s\n", line);
exit (99);
}
else
{
printf ("Device opened successfully\n\n");
for (i = 0; i < 4; i++)
{
drdaq_get_unit_info (line, sizeof (line), i, port);
printf ("%s\n", line);
}

ch = ' ';
while (ch != 'X')
{
printf ("\n");
printf ("Select an operation\n");
printf ("B - immediate block\n");
printf ("T - triggered block\n");
printf ("W - windowed block X - exit\n");
printf ("S - streaming\n");
printf ("I - individual reading\n");
ch = toupper (getch ());
printf ("\n");
switch (ch)
{
case 'B':
collect_block_immediate ();
break;

case 'T':
collect_block_triggered ();
break;

case 'W':
if (drdaq_is_streaming ())
{
collect_windowed_blocks ();
}
else
{
printf ("Windowed mode not supported on this device\n");
}
break;

case 'S':
if (drdaq_is_streaming ())
{
collect_streaming ();
}
else
{
printf ("Streaming mode not supported on this device\n");
}
break;

case 'I':
collect_individual ();
break;

case 'X':
/* Handled by outer loop */
break;

default:
printf ("Invalid operation\n");
break;
}
}

/* Essential for USB or NT
* not needed for LPT1 on Win95/Win98
*/
drdaq_close_unit (port);
}


}
thanks alot...... your help will be greatly appreciated....
Topic archived. No new replies allowed.