没法直接转换,需要手工,你把代码贴一贴看看。
转换的方法可以参考 pinvoke.net 这个网站中 windows api 的翻译
#include <stdio.h>
#include"1553_API_DLL.h"
#ifdef WIN32
#include <windows.h>
#endif
#define MY_DEV_NUM (0|PCI_1553_TYPE)
#define MY_CHANNEL_NUM 0
int main() {
CORE_U16 status, rtAddr,saAddr,tr;
CORE_U32 numMsgs, i, totalMsgCount, maxMsgs;
CORE_BM_MSG_BUFFER bmMessages[1000];
char c;
char filename[50];
FILE *fp;
/* Initialize */
printf("Initializing CORE . . . ");
if ( CORE_GEN_Full_Init(MY_DEV_NUM, MY_CHANNEL_NUM, 16) != SUCCESS )
printf("FAILURE.\n");
else
{
printf("Success.\n");
status = CORE_BM_Init(MY_DEV_NUM, MY_CHANNEL_NUM);
if (status == SUCCESS)
{
printf("Success.\n");
/* The BM can be configured with FILTERS to only capture messages for
* the desired Remote Terminals,Subaddresses and word count. In this case we
* will set the filter to capture any message.
*/
printf("Writing BM Filters (capture all) . . . ");
for (rtAddr=0; rtAddr<32; rtAddr++)
{
for(saAddr=0; saAddr<32; saAddr++)
for(tr=0;tr<2; tr++)
{
status = CORE_BM_FilterWrite(MY_DEV_NUM, MY_CHANNEL_NUM, rtAddr, saAddr,tr, 0xFFFFFFFF);
if (status != SUCCESS) break;
}
}
if (status == SUCCESS)
{
printf("Success.\n");
/* Each BM CDP buffer contains one 1553 message. We need to
* allocate the desired number of buffers in board memory to
* capture messages. In this case we will allocate enough
* memory for 1000 messages. This will create a circular
* buffer that will overwrite old messages and will always
* contain the the most recent 1000 messages.
*/
printf("Allocating BM CDP buffers . . . ");
status = CORE_BM_MessageAlloc(MY_DEV_NUM, MY_CHANNEL_NUM, 1000);
if (status == SUCCESS)
{
printf("Success.\n");
printf("\nInput filename to write messages to: ");
scanf("%s", filename);
printf("Input the number of messages to capture: ");
scanf("%d", &maxMsgs);
if ((fp = fopen(filename, "wb")) != NULL)
{
/* Now the BM is ready to start monitoring */
printf("Starting BM . . . ");
CORE_BM_Start(MY_DEV_NUM, MY_CHANNEL_NUM);
if (status == SUCCESS) {
printf("Success.\n");
totalMsgCount = 0;
while (totalMsgCount < maxMsgs) {
/* This will read up to 1000 messages from the board (which is the maximum
* our bmMessages array can hold in this example).
*/
status = CORE_BM_ReadNewMsgs(MY_DEV_NUM, MY_CHANNEL_NUM, 1000, &numMsgs, bmMessages);
if (status == SUCCESS) {
totalMsgCount += numMsgs;
/* Write the messages to the CDP file */
for (i=0; i<numMsgs; i++) {
printf("."); /* Display a . for each msg as an activity indicator */
fwrite(&bmMessages[i], sizeof(CORE_BM_MSG_BUFFER), 1, fp);
}
}
else printf("FAILURE on ADT_L1_1553_BM_ReadNewMsgs - Error = %d\n", status);
}
printf("Stopping BM . . . ");
CORE_BM_Stop(MY_DEV_NUM, MY_CHANNEL_NUM);
printf("%d messages were written to the file.\n", totalMsgCount);
fclose(fp);
}
else printf("FAILURE - Error = %d\n", status);
}
else printf("COULD NOT OPEN THE FILE!\n");
}
else printf("FAILURE - Error = %d\n", status);
}
else printf("FAILURE - Error = %d\n", status);
/* Close and exit */
printf("\nClosing . . . ");
status = CORE_LL_Close(MY_DEV_NUM);
if (status == SUCCESS) printf("Success.\n");
else printf("FAILURE - Error = %d\n", status);
}
else printf("FAILURE - Error = %d\n", status);
}
printf("\n***************** Finished *******************\n");
printf("Hit ENTER to exit.\n");
scanf("%c", &c);
return( 0 );
}