Hi,
Just need a bit of advice on some C++ related issues. I have the following:
Code:
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <windows.h>
#include "et1000.h"
#pragma comment( lib, "smbw32vc.lib" )
using namespace std;
//prototypes
// h = Hub, s = Slot, p = Port
void setTxParams (int h, int s, int p);
int main()
{
//Set Hub, Slot and Ports to be used.
int h1 = 0;
int s1 = 0;
int p1 = 0;
int h2 = 0;
int s2 = 0;
int p2 = 1;
unlink();
return 0;
}
void setTxParams (int h, int s, int p)
{
CHECKERROR(HTSetStructure(ETH_TRANSMIT, 0, 0, 0,
(void*) pETHTransmit, sizeof(ETHTransmit), h, s, p));
}
typedef struct tagETHTransmit
{
unsigned char ucTransmitMode; /* transmit mode:
CONTINUOUS_PACKET_MODE
SINGLE_BURST_MODE
MULTI_BURST_MODE
CONTINUOUS_BURST_MODE
ECHO_MODE */
unsigned short uiDataLength; /* number of bytes per frame, not
including 4 byte CRC */
} ETHTransmit;
First, the code is not complete (especially int main()), but there is enough for you to answer my question.
Is it ok to put the struct at the end of the code, like above? If not, where should I put it?
I have a lot of parameters that need to be specified to set up the transmit parameters. void setTxParams points to the struct. So, where do I set the values for the struct parameters?
In int main() like this:
Code:
ETHTransmit.ucTransmitMode = SINGLE_BURST_MODE;
or in void setTxParams(...) like this:
Code:
void setTxParams (int h, int s, int p)
{
ETHTransmit.ucTransmitMode = SINGLE_BURST_MODE;
CHECKERROR(HTSetStructure(ETH_TRANSMIT, 0, 0, 0,
(void*) pETHTransmit, sizeof(ETHTransmit), h, s, p));
}
Finally, is there anything more I may need to do that I may have left out?
Regards
Brownie
//Using Microsoft Visual C++ Express 2008 on a Windows XP machine