infratec wrote:
Hi,
Code:
*Packet = AllocateMemory(100)
G_Port = 4110
Pos = 0
PokeB(*Packet + Pos + 1, $00)
PokeB(*Packet + Pos + 2, $00)
PokeB(*Packet + Pos + 3, $00)
;Port
PokeU(*Packet + Pos + 4, G_Port)
PokeB(*Packet + Pos + 6, $00)
PokeB(*Packet + Pos + 7, $00)
PokeB(*Packet + Pos + 8, $00)
PokeB(*Packet + Pos + 9, $00)
For i = 0 To 9
Debug RSet(Hex(PeekB(*Packet + i), #PB_Byte), 2, "0")
Next i
FreeMemory(*Packet)
Results in:
Code:
00 00 00 00 0E 10 00 00 00 00
0x100E is correct!
What you need is to convert this stuff in network byte order (Big-Endian).
But I can not see 0x1010
Bernd
P.S.: Maybe the 0x0E is overwritten by something else.
Strange it works now. Must be I have setup the Pos wrong carrying the pointer from the beginning of the packet. Here is how I have it now and works (bytes need to be reversed back in order).
Code:
PokeU(*Packet + Pos + 4, G_Port)
PByte1 = PeekB(*Packet + Pos + 4)
PByte2 = PeekB(*Packet + Pos + 5)
PokeB(*Packet + Pos + 4, PByte2)
PokeB(*Packet + Pos + 5, PByte1)
Example:
Code:
*Packet = AllocateMemory(100)
G_Port = 4110
Pos = 0
PokeB(*Packet + Pos + 1, $00)
PokeB(*Packet + Pos + 2, $00)
PokeB(*Packet + Pos + 3, $00)
;Port
PokeU(*Packet + Pos + 4, G_Port)
PokeB(*Packet + Pos + 6, $00)
PokeB(*Packet + Pos + 7, $00)
PokeB(*Packet + Pos + 8, $00)
PokeB(*Packet + Pos + 9, $00)
PokeU(*Packet + Pos + 4, G_Port)
PByte1 = PeekB(*Packet + Pos + 4)
PByte2 = PeekB(*Packet + Pos + 5)
PokeB(*Packet + Pos + 4, PByte2)
PokeB(*Packet + Pos + 5, PByte1)
For i = 0 To 9
Debug RSet(Hex(PeekB(*Packet + i), #PB_Byte), 2, "0")
Next i