Wie kann ich bitte den Filemapempfänger auf Bereitschaft stellen , damit er nur Daten raus gibt wenn er vom Sender etwas empfangen hat? Der Sender sendet jetzt mal alle 400 ms.
Sender:
Code: Alles auswählen
XIncludeFile "filemap.pbi"
Global wert.l,text_e.s
*MemoryID = AllocateMemory(1024)
Define *MemoryID = FileMap::Create("MyMemory", 1024)
Enumeration
#Window_0
#Editor_0
EndEnumeration
OpenWindow(#Window_0,1000,200,420,500,"esp-webserver-http", #PB_Window_SystemMenu)
EditorGadget(#Editor_0, 10, 180, 300,280)
AddWindowTimer(#Window_0, 123, 400)
Repeat
Event = WaitWindowEvent(1)
If Event = #PB_Event_Timer And EventTimer() = 123
wert=wert+1
PokeS(*MemoryID+10,Str(wert))
PokeL(*MemoryID,#False)
EndIf
Select Event
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
CloseWindow(#Window_0)
Break
EndIf
EndSelect
ForEver
FileMap::Close(*MemoryID)
Code: Alles auswählen
XIncludeFile "filemap.pbi"
Global text_e.s
Enumeration
#Window_0
#Editor_0
EndEnumeration
*MemoryID = AllocateMemory(1024)
Define *MemoryID = FileMap::Open("MyMemory")
OpenWindow(#Window_0,1000,200,420,500,"esp-webserver-http", #PB_Window_SystemMenu)
EditorGadget(#Editor_0, 10, 180, 300,280)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
CloseWindow(#Window_0)
Break
EndIf
EndSelect
????????????????text_e + PeekS(*MemoryID+10)+Chr(10)
????????????????SetGadgetText(#Editor_0, text_e)
ForEver
FileMap::Close(*MemoryID)
Die filemap.pbi :
Code: Alles auswählen
DeclareModule FileMap
Declare Create(Name.s, Size.i, Security = #False)
Declare Open(Name.s)
Declare Close(*Mem)
EndDeclareModule
Module FileMap
Global NewMap hMap.i()
Global SA.SECURITY_ATTRIBUTES
Global pSD.SECURITY_DESCRIPTOR
Global IsInitSecurity
Procedure Create(Name.s, Size.i, Security = #False)
Protected handle, *mem
If Security
If Not IsInitSecurity
If Not InitializeSecurityDescriptor_(@pSD, #SECURITY_DESCRIPTOR_REVISION)
ProcedureReturn 0
EndIf
If Not SetSecurityDescriptorDacl_(@pSD, #True, #Null, #False)
ProcedureReturn 0
EndIf
SA\nLength = SizeOf(SA)
SA\lpSecurityDescriptor = @pSD
SA\bInheritHandle = #True
IsInitSecurity = #True
EndIf
handle = CreateFileMapping_(#INVALID_HANDLE_VALUE, @SA, #PAGE_READWRITE | #SEC_COMMIT | #SEC_NOCACHE, 0, Size, Name)
Else
handle = CreateFileMapping_(#INVALID_HANDLE_VALUE, 0, #PAGE_READWRITE | #SEC_COMMIT | #SEC_NOCACHE, 0, Size, Name)
EndIf
If handle
*mem = MapViewOfFile_(handle, #FILE_MAP_ALL_ACCESS, 0, 0, 0)
hMap(Str(*mem)) = handle
ProcedureReturn *mem
EndIf
EndProcedure
Procedure Open(Name.s)
Protected handle, *mem
handle = OpenFileMapping_(#FILE_MAP_ALL_ACCESS, 0, Name)
If handle
*mem = MapViewOfFile_(handle, #FILE_MAP_ALL_ACCESS, 0, 0, 0)
hMap(Str(*mem)) = handle
ProcedureReturn *mem
EndIf
EndProcedure
Procedure Close(*Mem)
Protected result
UnmapViewOfFile_(*Mem)
result = CloseHandle_(hMap(Str(*Mem)))
DeleteMapElement(hMap(), Str(*Mem))
ProcedureReturn result
EndProcedure
EndModule

