Skip to content
Snippets Groups Projects
Commit 8776bc86 authored by Attie Grande's avatar Attie Grande
Browse files

initial commit

Original file timestamps:

  2011-04-27  Car.pde   (from 'Arduino_archive' directory)
  2011-05-02  Form1.frm (from 'code' SVN repository)
parents
Branches main
Tags v1
No related merge requests found
# HEX WHEELER
This ancient project is one of my first ever electronics modifications - a hardware hack for my brother's "_HEX WHEELER_" / "_RX03_" remote control car.
The original radio control had been lost, so an [Arduino Fio](https://docs.arduino.cc/retired/boards/arduino-fio/) and [XBee S1](https://www.sparkfun.com/products/retired/8665) were wired in place of the receiver.
The new controller is a Windows PC, with [libxbee1](https://gitlab.attie.co.uk/libxbee/libxbee1) and a VB6 application.
## Car
Last time I checked, the car's XBee was on channel 0x10, so matching up whatever XBee you connect to the PC is probably a good idea.
Also, sadly, it seems that the middle wheels no longer orbit the front wheels - the PC buttons work, the signals are coming out of the FIO, but nothing happens.
It seems I managed to wire up the Fio with very little slack, and I will not be desoldering anything to take the lid off for a better view / extra commentary.
If I remember correctly, all three wheels on each side are driven by an H-Bridge, and I'm injecting a PWM signal into each side to control it.
### Building
**NOTE:** This build is entirely untested (I re-created it while archiving the project)... it's simple, so it probably works?!
```bash
cd arduino
python3 -m venv venv
. venv/bin/activate
pip install -U pip
pip install platformio
pio run
```
## Controller
The VB6 application expects the XBee to be configured at 57600 baud, with no flow control, on COM8... there is no configuration.
Normal `<up>` / `<down>` / `<left>` / `<right>` buttons work for driving, and the speed (actually more like torque) can be adjusted with the unmarked slider.
Alternatively, you can click and move the mouse around in the X/Y area, to get proportional control.
The `,` and `.` buttons are supposed to make the middle wheels orbit, but they don't.
### XBee Config
```xbee
+++
ATAP1
ATD60
ATD70
ATCH10
ATWR
ATFR
```
## Images
![hex wheeler](./images/hex-wheeler.jpg)
![internals](./images/internals.jpg)
![vb6 application](./images/screenshot.png)
/venv/
/.pio/
[env:hexwheeler]
platform = atmelavr
board = fio
framework = arduino
monitor_speed = 57600
const int ledPin = 13; // status LED
const int leftFwd = 6;
const int leftRev = 9;
const int rightFwd = 10;
const int rightRev = 11;
const int wheelsCW = 7;
const int wheelsCCW = 8;
unsigned long actionTimeout;
char command[3];
/* byte 1 = left speed (-128 - 127)
byte 2 = right speed (-128 - 127)
byte 3 = bit 0 = rotate wheels (CW from left of car)
bit 1 = rotate wheels (CCW from left of car) */
void resetOutputs() {
analogWrite(leftFwd, 0);
analogWrite(leftRev, 0);
analogWrite(rightFwd, 0);
analogWrite(rightRev, 0);
digitalWrite(wheelsCW, LOW);
digitalWrite(wheelsCCW, LOW);
digitalWrite(ledPin, HIGH);
actionTimeout = 0;
}
void setup() {
Serial.begin(57600);
resetOutputs();
pinMode(ledPin, OUTPUT);
pinMode(leftFwd, OUTPUT);
pinMode(leftRev, OUTPUT);
pinMode(rightFwd, OUTPUT);
pinMode(rightRev, OUTPUT);
pinMode(wheelsCW, OUTPUT);
pinMode(wheelsCCW, OUTPUT);
actionTimeout = 0;
}
unsigned char getEscaped() {
unsigned char in;
in = Serial.read();
if (in == 0xFE) {
in = Serial.read();
in ^= 0x20;
}
return in;
}
void setSpeeds(int Fwd, int Rev, signed char speed) {
unsigned char speed2;
unsigned char forward;
speed2 = speed & 0x7f;
speed2 <<= 1;
forward = !(speed & 0x80);
speed &= 0x7F;
if (speed == 0) {
analogWrite(Fwd, 0);
analogWrite(Rev, 0);
} else if (forward) {
analogWrite(Fwd, speed2);
analogWrite(Rev, 0);
} else {
analogWrite(Fwd, 0);
analogWrite(Rev, speed2);
}
}
void loop() {
if (Serial.available() >= 4) {
unsigned char in;
if ((in = Serial.read()) != 0xFF) return;
command[0] = getEscaped();
command[1] = getEscaped();
command[2] = getEscaped();
setSpeeds(leftFwd, leftRev, command[0]);
setSpeeds(rightFwd, rightRev, command[1]);
if (command[2] & 0x01) {
digitalWrite(wheelsCW, HIGH);
digitalWrite(wheelsCCW, LOW);
} else if (command[2] & 0x02) {
digitalWrite(wheelsCW, LOW);
digitalWrite(wheelsCCW, HIGH);
} else if (!(command[2] & 0x03)) {
digitalWrite(wheelsCW, LOW);
digitalWrite(wheelsCCW, LOW);
}
actionTimeout = millis() + 250; /* this will last for 0.25 seconds */
digitalWrite(ledPin, LOW);
} else if (millis() > actionTimeout) {
resetOutputs();
}
}
images/hex-wheeler.jpg

411 KiB

images/internals.jpg

205 KiB

images/screenshot.png

4.54 KiB

/libxbee.dll
/Project1.exe
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 6255
ClientLeft = 120
ClientTop = 450
ClientWidth = 9000
LinkTopic = "Form1"
ScaleHeight = 6255
ScaleWidth = 9000
StartUpPosition = 3 'Windows Default
Begin VB.VScrollBar power
Height = 2475
Left = 2040
Max = 127
TabIndex = 2
Top = 2340
Value = 127
Width = 435
End
Begin VB.Timer loader
Interval = 10
Left = 60
Top = 60
End
Begin VB.Frame pad
Height = 4155
Left = 4080
TabIndex = 1
Top = 1020
Width = 4275
Begin VB.Shape padPoint
FillColor = &H000000FF&
FillStyle = 0 'Solid
Height = 255
Left = 0
Shape = 3 'Circle
Top = 0
Visible = 0 'False
Width = 255
End
Begin VB.Line Line2
BorderColor = &H80000000&
X1 = 2130
X2 = 2130
Y1 = 90
Y2 = 4125
End
Begin VB.Line Line1
BorderColor = &H80000000&
X1 = 0
X2 = 4260
Y1 = 2070
Y2 = 2070
End
End
Begin VB.TextBox Text1
Height = 495
Left = 2520
TabIndex = 0
Top = 1080
Width = 915
End
Begin VB.Timer Timer1
Interval = 10
Left = 960
Top = 600
End
Begin VB.Shape sright
FillColor = &H00008000&
FillStyle = 0 'Solid
Height = 315
Left = 1020
Shape = 3 'Circle
Top = 1620
Width = 315
End
Begin VB.Shape sleft
FillColor = &H00008000&
FillStyle = 0 'Solid
Height = 315
Left = 300
Shape = 3 'Circle
Top = 1620
Width = 315
End
Begin VB.Shape srev
FillColor = &H00008000&
FillStyle = 0 'Solid
Height = 315
Left = 660
Shape = 3 'Circle
Top = 1620
Width = 315
End
Begin VB.Shape sfwd
FillColor = &H00008000&
FillStyle = 0 'Solid
Height = 315
Left = 660
Shape = 3 'Circle
Top = 1260
Width = 315
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim bfwd As Boolean
Dim brev As Boolean
Dim bleft As Boolean
Dim bright As Boolean
Dim bcw As Boolean
Dim bccw As Boolean
Dim bpad As Boolean
Dim con As Long
Private Sub Form_Load()
Me.Show
Me.Caption = "Please wait..."
End Sub
Private Sub loader_Timer()
loader.Enabled = False
xbee_setupDebugAPI "COM8", 57600, "libxbee.log", "+", 250
Me.Caption = "Form1"
DoEvents
con = xbee_newcon_64bit(0, xbee_64bitData, &H13A200, &H403DF072)
End Sub
Private Sub pad_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
pad_MouseMove Button, Shift, X, Y
End Sub
Private Sub pad_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
pad_MouseMove Button, Shift, X, Y
End Sub
Private Sub pad_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 0 Then
bpad = False
padPoint.Visible = False
Exit Sub
ElseIf Button = 1 Then
bpad = True
padPoint.Visible = True
Else
Exit Sub
End If
If X < 0 Then X = 0
If X > pad.Width Then X = pad.Width
If Y < 0 Then Y = 0
If Y > pad.Height Then Y = pad.Height
padPoint.Left = X - (padPoint.Width / 2)
padPoint.Top = Y - (padPoint.Height / 2)
End Sub
Private Sub power_Change()
Text1.SetFocus
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 38 Then ' Up
bfwd = True
ElseIf KeyCode = 40 Then ' Down
brev = True
ElseIf KeyCode = 37 Then ' Left
bleft = True
ElseIf KeyCode = 39 Then ' Right
bright = True
ElseIf KeyCode = 188 Then ' ','
bccw = True
ElseIf KeyCode = 190 Then ' '.'
bcw = True
Else
Me.Caption = KeyCode
End If
Text1.text = ""
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 38 Then
bfwd = False
ElseIf KeyCode = 40 Then
brev = False
ElseIf KeyCode = 37 Then
bleft = False
ElseIf KeyCode = 39 Then
bright = False
ElseIf KeyCode = 188 Then
bccw = False
ElseIf KeyCode = 190 Then
bcw = False
End If
Text1.text = ""
End Sub
Private Sub setHUD(b As Boolean, s As Shape)
If b Then
s.FillColor = &HFF00&
Else
s.FillColor = &H8000&
End If
End Sub
Private Sub Timer1_Timer()
Dim rot As Byte
Dim mleft As Byte
Dim mright As Byte
setHUD bfwd, sfwd
setHUD brev, srev
setHUD bleft, sleft
setHUD bright, sright
If bcw Then
rot = &H1
ElseIf bccw Then
rot = &H2
End If
If bpad Then
Dim lspeed As Double
Dim rspeed As Double
Dim offset As Double
lspeed = padPoint.Top + (padPoint.Height / 2)
lspeed = Round((lspeed / pad.Height) * 255, 0)
If lspeed < 128 Then
lspeed = 128 - lspeed
If lspeed > 127 Then lspeed = 127
End If
rspeed = lspeed
offset = padPoint.Left + (padPoint.Width / 2)
offset = Round(offset / pad.Width, 2)
If offset < 0.5 Then
offset = -(0.5 - offset)
Else
offset = offset - 0.5
End If
offset = offset * 2
If lspeed < 128 Then ' fwd
If offset < 0 Then
lspeed = lspeed * (1 - -offset)
Else
rspeed = rspeed * (1 - offset)
End If
Else 'rev
lspeed = lspeed - 128
rspeed = rspeed - 128
If offset < 0 Then
lspeed = lspeed * (1 - -offset)
Else
rspeed = rspeed * (1 - offset)
End If
lspeed = lspeed + 128
rspeed = rspeed + 128
End If
If lspeed < 0 Then lspeed = 0
If lspeed > 255 Then lspeed = 255
If rspeed < 0 Then rspeed = 0
If rspeed > 255 Then rspeed = 255
Me.Caption = lspeed & " - " & rspeed & " - " & offset
mleft = CInt(lspeed)
mright = CInt(rspeed)
ElseIf bfwd And bleft Then
mleft = 0
mright = power.Value
ElseIf bfwd And bright Then
mleft = power.Value
mright = 0
ElseIf bfwd Then
mleft = power.Value
mright = power.Value
ElseIf brev And bleft Then
mleft = power.Value Or &H80
mright = 0
ElseIf brev And bright Then
mleft = 0
mright = power.Value Or &H80
ElseIf brev Then
mleft = power.Value Or &H80
mright = power.Value Or &H80
ElseIf bleft Then
mleft = power.Value Or &H80
mright = power.Value
ElseIf bright Then
mleft = power.Value
mright = power.Value Or &H80
Else
mleft = 0
mright = 0
End If
If loader.Enabled = True Then Exit Sub
xbee_sendstring con, Chr(&HFF) & Chr(mleft) & Chr(mright) & Chr(rot)
End Sub
Type=Exe
Form=Form1.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\Windows\system32\stdole2.tlb#OLE Automation
Object={648A5603-2C6E-101B-82B6-000000000014}#1.1#0; MSCOMM32.OCX
Module=libxbee; libxbee.bas
IconForm="Form1"
Startup="Form1"
ExeName32="Project1.exe"
Command32=""
Name="Project1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
Form1 = 217, 219, 926, 831, Z, 25, 25, 734, 637, C
libxbee = 0, 0, 0, 0, C
Attribute VB_Name = "libxbee"
Option Explicit
Enum xbee_types
xbee_unknown
xbee_localAT
xbee_remoteAT
xbee_modemStatus
xbee_txStatus
' XBee Series 1 stuff
xbee_16bitRemoteAT
xbee_64bitRemoteAT
xbee_16bitData
xbee_64bitData
xbee_16bitIO
xbee_64bitIO
' XBee Series 2 stuff
xbee2_data
xbee2_txStatus
End Enum
Type xbee_sample
'# X A5 A4 A3 A2 A1 A0 D8 D7 D6 D5 D4 D3 D2 D1 D0
IOmask As Integer
'# X X X X X X X D8 D7 D6 D5 D4 D3 D2 D1 D0
IOdigital As Integer
'# X X X X X D D D D D D D D D D D
IOanalog(0 To 5) As Integer
End Type
Type xbee_pkt
flags As Long '# bit 0 - is64
'# bit 1 - dataPkt
'# bit 2 - txStatusPkt
'# bit 3 - modemStatusPkt
'# bit 4 - remoteATPkt
'# bit 5 - IOPkt
frameID As Byte
atCmd(0 To 1) As Byte
status As Byte
samples As Byte
RSSI As Byte
Addr16(0 To 1) As Byte
Addr64(0 To 7) As Byte
data(0 To 127) As Byte
datalen As Long
type As Long ' enum xbee_types
SPARE As Long ' IGNORE THIS (is the pointer to the next packet in C... this will ALWAYS be 0 in VB)
IOdata As xbee_sample
End Type
Private OldhWndHandler As Long
Private ActivehWnd As Long
Private callbackMessageID As Long
Private Callbacks As New Collection
Public Declare Sub xbee_free Lib "libxbee.dll" (ByVal ptr As Long)
Public Declare Function xbee_setup Lib "libxbee.dll" (ByVal port As String, ByVal baudRate As Long) As Long
Public Declare Function xbee_setupDebug Lib "libxbee.dll" (ByVal port As String, ByVal baudRate As Long, ByVal logfile As String) As Long
Private Declare Function xbee_setupDebugAPIRaw Lib "libxbee.dll" Alias "xbee_setupDebugAPI" (ByVal port As String, ByVal baudRate As Long, ByVal logfile As String, ByVal cmdSeq As Byte, ByVal cmdTime As Long) As Long
Private Declare Function xbee_setupAPIRaw Lib "libxbee.dll" Alias "xbee_setupAPI" (ByVal port As String, ByVal baudRate As Long, ByVal cmdSeq As Byte, ByVal cmdTime As Long) As Long
Public Declare Function xbee_end Lib "libxbee.dll" () As Long
Public Declare Function xbee_newcon_simple Lib "libxbee.dll" (ByVal frameID As Byte, ByVal conType As Long) As Long 'xbee_con *
Public Declare Function xbee_newcon_16bit Lib "libxbee.dll" (ByVal frameID As Byte, ByVal conType As Long, ByVal addr16bit As Long) As Long 'xbee_con *
Public Declare Function xbee_newcon_64bit Lib "libxbee.dll" (ByVal frameID As Byte, ByVal conType As Long, ByVal addr64bitLow As Long, ByVal addr64bitHigh As Long) As Long 'xbee_con *
Public Declare Sub xbee_enableACKwait Lib "libxbee.dll" (ByVal con As Long)
Public Declare Sub xbee_disableACKwait Lib "libxbee.dll" (ByVal con As Long)
Public Declare Sub xbee_enableDestroySelf Lib "libxbee.dll" (ByVal con As Long)
Private Declare Sub xbee_enableCallbacksRaw Lib "libxbee.dll" Alias "xbee_enableCallbacks" (ByVal hWnd As Long, ByVal uMsg As Long)
Private Declare Sub xbee_attachCallbackRaw Lib "libxbee.dll" Alias "xbee_attachCallback" (ByVal con As Long)
Private Declare Sub xbee_detachCallbackRaw Lib "libxbee.dll" Alias "xbee_detachCallback" (ByVal con As Long)
Private Declare Function xbee_runCallback Lib "libxbee.dll" (ByVal func As Long, ByVal con As Long, ByVal pkt As Long) As Long
Public Declare Sub xbee_endcon2 Lib "libxbee.dll" (ByVal con As Long)
Public Declare Sub xbee_flushcon Lib "libxbee.dll" (ByVal con As Long)
Public Declare Function xbee_senddata Lib "libxbee.dll" Alias "xbee_nsenddata" (ByVal con As Long, ByRef data As Byte, ByVal Length As Long) As Long
Private Declare Function xbee_senddata_str Lib "libxbee.dll" Alias "xbee_nsenddata" (ByVal con As Long, ByVal data As String, ByVal Length As Long) As Long
Public Declare Function xbee_getpacketRaw Lib "libxbee.dll" Alias "xbee_getpacket" (ByVal con As Long) As Long 'xbee_pkt *
Public Declare Function xbee_hasanalog Lib "libxbee.dll" (ByRef pkt As xbee_pkt, ByVal sample As Long, ByVal inputPin As Long) As Long
Public Declare Function xbee_getanalog Lib "libxbee.dll" (ByRef pkt As xbee_pkt, ByVal sample As Long, ByVal inputPin As Long, ByVal Vref As Double) As Double
Public Declare Function xbee_hasdigital Lib "libxbee.dll" (ByRef pkt As xbee_pkt, ByVal sample As Long, ByVal inputPin As Long) As Long
Public Declare Function xbee_getdigital Lib "libxbee.dll" (ByRef pkt As xbee_pkt, ByVal sample As Long, ByVal inputPin As Long) As Long
Private Declare Function xbee_svn_versionRaw Lib "libxbee.dll" Alias "xbee_svn_version" () As Long
Public Declare Sub xbee_logit Lib "libxbee.dll" (ByVal text As String)
'###########################################################################################################################################################################
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As Long
Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_DESTROY = &H2
Private Const GWL_WNDPROC = -4
Public Function PointerToString(lngPtr As Long) As String
Dim strTemp As String
Dim lngLen As Long
If lngPtr Then
lngLen = lstrlenW(lngPtr) * 2
If lngLen Then
strTemp = Space(lngLen)
CopyMemory ByVal strTemp, ByVal lngPtr, lngLen
PointerToString = Replace(strTemp, Chr(0), "")
End If
End If
End Function
Public Function ArrayToString(data() As Byte, Optional lb As Integer = -1, Optional ub As Integer = -1) As String
Dim tmp As String
Dim i
If lb = -1 Then lb = LBound(data)
If ub = -1 Then ub = UBound(data)
tmp = ""
For i = lb To ub
If (data(i) = 0) Then Exit For
tmp = tmp & Chr(data(i))
Next
ArrayToString = tmp
End Function
Public Function xbee_pointerToPacket(lngPtr As Long) As xbee_pkt
Dim p As xbee_pkt
CopyMemory p, ByVal lngPtr, Len(p)
xbee_pointerToPacket = p
End Function
Public Sub libxbee_load()
' this function is simply to get VB6 to call a libxbee function
' if you are using any C DLLs that make use of libxbee, then you should call this function first so that VB6 will load libxbee
xbee_svn_versionRaw
End Sub
Public Function xbee_svn_version() As String
xbee_svn_version = PointerToString(xbee_svn_versionRaw())
End Function
Public Function xbee_setupAPI(ByVal port As String, ByVal baudRate As Long, ByVal cmdSeq As String, ByVal cmdTime As Long)
xbee_setupAPI = xbee_setupAPIRaw(port, baudRate, Asc(cmdSeq), cmdTime)
End Function
Public Function xbee_setupDebugAPI(ByVal port As String, ByVal baudRate As Long, ByVal logfile As String, ByVal cmdSeq As String, ByVal cmdTime As Long)
xbee_setupDebugAPI = xbee_setupDebugAPIRaw(port, baudRate, logfile, Asc(cmdSeq), cmdTime)
End Function
Private Sub xbee_ensureMessageID()
If callbackMessageID = 0 Then
callbackMessageID = RegisterWindowMessage("libxbee")
End If
xbee_enableCallbacksRaw ActivehWnd, callbackMessageID
End Sub
Public Sub xbee_attachCallback(ByVal con As Long, ByVal func As Long)
Dim t(0 To 1) As Long
Dim c As String
If ActivehWnd = 0 Then
Debug.Print "Callbacks not enabled!"
Exit Sub
End If
xbee_ensureMessageID
c = CStr(con)
t(0) = con
t(1) = func
On Error Resume Next
Callbacks.Remove c
Callbacks.Add t, c
On Error GoTo 0
xbee_attachCallbackRaw con
End Sub
Public Sub xbee_detachCallback(ByVal con As Long)
If ActivehWnd = 0 Then
Debug.Print "Callbacks not enabled!"
Exit Sub
End If
On Error Resume Next
xbee_detachCallbackRaw con
Callbacks.Remove CStr(con)
End Sub
Public Sub xbee_enableCallbacks(ByVal hWnd As Long)
If ActivehWnd <> 0 Then
Debug.Print "Callbacks already enabled!"
Exit Sub
End If
ActivehWnd = hWnd
OldhWndHandler = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf libxbee.xbee_messageHandler)
xbee_ensureMessageID
End Sub
Public Sub xbee_disableCallbacks()
Dim id As Variant
If ActivehWnd = 0 Then
Debug.Print "Callbacks not enabled!"
Exit Sub
End If
For Each id In Callbacks
xbee_detachCallback id(0)
Next
SetWindowLong ActivehWnd, GWL_WNDPROC, OldhWndHandler
ActivehWnd = 0
OldhWndHandler = 0
End Sub
Private Function xbee_messageHandler(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If uMsg = callbackMessageID Then
Dim t As Long
On Error Resume Next
Err.Clear
t = Callbacks.Item(CStr(wParam))(1)
If Err.Number = 0 Then
On Error GoTo 0
xbee_messageHandler = xbee_runCallback(t, wParam, lParam)
Exit Function
End If
On Error GoTo 0
xbee_logit "Unable to match Connection with active callback!"
End If
xbee_messageHandler = CallWindowProc(OldhWndHandler, hWnd, uMsg, wParam, lParam)
If uMsg = WM_DESTROY And ActivehWnd <> 0 Then
' Disable the MessageHandler if the form "unload" event is detected
xbee_disableCallbacks
End If
End Function
Public Sub xbee_endcon(ByRef con As Long)
xbee_endcon2 con
con = 0
End Sub
Public Function xbee_sendstring(ByVal con As Long, ByVal str As String)
xbee_sendstring = xbee_senddata_str(con, str, Len(str))
End Function
Public Function xbee_getpacketPtr(ByVal con As Long, ByRef pkt As Long) As Integer
Dim ptr As Long
ptr = xbee_getpacketRaw(con)
If ptr = 0 Then
pkt = 0
xbee_getpacketPtr = 0
Exit Function
End If
pkt = ptr
xbee_getpacketPtr = 1
End Function
Public Function xbee_getpacket(ByVal con As Long, ByRef pkt As xbee_pkt) As Integer
Dim ptr As Long
ptr = xbee_getpacketRaw(con)
If ptr = 0 Then
xbee_getpacket = 0
Exit Function
End If
pkt = xbee_pointerToPacket(ptr)
xbee_free ptr
xbee_getpacket = 1
End Function
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment