beautypg.com

Fairbanks FB3000 Kernel Program Operators Manual User Manual

Page 48

background image

Appendix II: I/O Addresses & Controls

04/12

48

51146 Rev. 3

SHARED MEMORY (KERNEL MAPPED OUTPUT)

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

// Sample code to read Kernel Mapped Output (Shared Memory)

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

// FileMap Memory Structure

struct FileMapStruct

{

unsigned char data[256]; // configured output string from kernel

unsigned char command[2]; // command to return to kernel i.e. “z” = zero all scales, “Z1” =
zero scale 1

int length; // length of string in data

int counter; // sequential number

char status[128]; // kernel status

};

bool TScaleForm::ReadMappedOutput(char *input)

{

bool result = false;

bool CommandSent = false;

if( MappedOutputHandle == NULL )

{

wSemaphore = CreateSemaphore(NULL, 1, 1, “Output1 Write");

if( wSemaphore == NULL )

return 0;

rSemaphore = CreateSemaphore(NULL, 0, 1, “Output1 Read");

if( rSemaphore == NULL ) {

CloseHandle(wSemaphore);

wSemaphore = NULL;

return 0;

}