-
How to call/use function
Hi,
I will set the pretext:
Code:
typedef struct
{
ubyte
command;
ubyte
data_length;
ubyte
data[MAX_DATA_LENGTH];
WORD_UNION
CRC;
}COMMAND_PACKET;
void send_packet(COMMAND_PACKET *packet);
How would I call/use the function send_packet() in the main()
Can you give me an example of using it?
Thanks
-
Something like this:
Code:
int main()
{
COMMAND_PACKET package;
package.command = some_value;
send_packet(&package);
return 0;
}
-
Thank you Ideswa. That worked a charm.
But I have another question:
Code:
//============================================================================
// 631_WinTest Code.
// Copyright 2001-2004, Crystalfontz America, Inc. Written by Brent A. Crosby
//
// You may use this code in any project (including commercial) as long as
// at least one of the intents of the project is to communicate with a
// Crystalfontz display.
//
// http://www.crystalfontz.com [email protected]
//============================================================================
typedef unsigned char ubyte;
typedef signed char sbyte;
typedef unsigned short word;
typedef unsigned long dword;
typedef union
{
ubyte
as_bytes[2];
word
as_word;
} WORD_UNION;
typedef struct
{
ubyte
command;
ubyte
data_length;
ubyte
data[MAX_DATA_LENGTH];
WORD_UNION
CRC;
}COMMAND_PACKET;
I want to be able to write:
Code:
COMMAND_PACKET *packet;
packet->CRC->as_word = //return of some function
but it will not compile?
Do you know how to fix this?
-
Probably because you CRC isn't a pointer? So you should use
Code:
packet->CRC.as_word = ...
Edit: Also, your packet, as defined above, does not have any memory assigned to it, so CRC and any other members of the COMMAND_PACKET doesn't actually exist. Only a pointer to hold the address WHEN it gets created exists.
--
Mats