Microsoft and the Propeller
NWCCTV
Posts: 3,629
in Propeller 1
I know there is a way for the Stamp to communicate using Visual Basic and Visual C but has anyone accomplished this with the Propeller yet? I have some project ideas that would really benefit from the use of VB and VC but have not found any info on this subject.

Comments
I think it would be pretty easy to translate PBASIC serial interface code to Spin.
As JonnyMac points out, this sort of thing should be easier with the Propeller than it was with a BS2.
ON THE PROPELLER
CON _CLKMODE = XTAL1 + PLL16X 'Setting up the clock mode _XINFREQ = 5_000_000 'Setting up the frequency MCU_PROGRX = 30 MCU_PROGTX = 31 VAR byte buffer[30] OBJ SIO : "FullDuplexSerial" PRI ReceiveTest SIO.Start(MCU_PROGTX,MCU_PROGRX,%0000,38_400) repeat ' forever ' fetch and display current vote counts GetDelimitedString(@buffer) { display string from buffer here: I was using a 4D Systems uLCD32 display the code for which has been omitted here for clarity, since you probably dont have one of them anyway. } PRI GetDelimitedString(psz) | n n := 29 repeat while (n--) if (byte[psz] := SIO.Rx) == CR quit psz++ byte[psz]~ ' zero terminate itIn Visual Basic (6.0 in my case)
Presuming a form is present containing an MSCOMM control named MSComm1; a ComboBox named cb1; and two CommandButtons named cmdRun and cmdQuit.
Option Explicit Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Dim cease As Boolean Private Sub Form_Load() SerialEnumerator.EnumSerialPorts cb1 cease = False End Sub Private Sub Form_Terminate() If MSComm1.PortOpen = True Then MSComm1.PortOpen = False ' this incidentally reboots the MCU End If End Sub Private Sub Form_Unload(Cancel As Integer) cease = True ' cause it to quit, hopefully End Sub Private Sub cb1_Click() cmdRun.Enabled = True End Sub Private Sub cmdRun_Click() If cmdRun.Caption = "Run" Then cmdRun.Caption = "Running" cease = False cmdQuit.Enabled = True MSComm1.CommPort = CInt(Right(cb1.List(cb1.ListIndex), Len(cb1.List(cb1.ListIndex)) - 3)) ' Defined COM port available on PC (COM7 for my EEE laptop) MSComm1.InputLen = 0 MSComm1.Settings = "38400, N, 8, 1" MSComm1.PortOpen = True ' Run End If cmdRun.Caption = "Run" cease = True cmdQuit.Enabled = False If MSComm1.PortOpen = True Then MSComm1.PortOpen = False End If End Sub Private Sub cmdQuit_Click() cease = True End Sub Private Sub Run() On Error Resume Next While Not cease DoEvents MSComm1.Output = "Hola Propeller" + vbCr ' forward to MCU for processing Sleep 250 'mS Wend End SubAnd in addition a module named SerialEnumerator containing the following code:
Option Explicit '--- for CreateFile Private Const GENERIC_READ As Long = &H80000000 Private Const GENERIC_WRITE As Long = &H40000000 Private Const OPEN_EXISTING As Long = 3 Private Const INVALID_HANDLE_VALUE As Long = -1 '--- error codes Private Const ERROR_ACCESS_DENIED As Long = 5& Private Const ERROR_GEN_FAILURE As Long = 31& Private Const ERROR_SHARING_VIOLATION As Long = 32& Private Const ERROR_SEM_TIMEOUT As Long = 121& Private Declare Function QueryDosDevice Lib "kernel32" Alias "QueryDosDeviceA" (ByVal lpDeviceName As Long, ByVal lpTargetPath As String, ByVal ucchMax As Long) As Long Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Function PrintError(sFunc As String) Debug.Print sFunc; ": "; Error End Function Public Function IsNT() As Boolean IsNT = True End Function Public Function EnumSerialPorts(ByRef cb As ComboBox) As Variant Const FUNC_NAME As String = "EnumSerialPorts" Dim sBuffer As String Dim lIdx As Long Dim hFile As Long Dim vRet As Variant Dim lCount As Long On Error GoTo EH ReDim vRet(0 To 255) As Variant If IsNT Then sBuffer = String$(100000, 1) Call QueryDosDevice(0, sBuffer, Len(sBuffer)) sBuffer = Chr$(0) & sBuffer For lIdx = 1 To 255 If InStr(1, sBuffer, Chr$(0) & "COM" & lIdx & Chr$(0), vbTextCompare) > 0 Then vRet(lCount) = "COM" & lIdx cb.AddItem ("COM" & lIdx) lCount = lCount + 1 End If Next Else For lIdx = 1 To 255 hFile = CreateFile("COM" & lIdx, GENERIC_READ Or GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0) If hFile = INVALID_HANDLE_VALUE Then Select Case Err.LastDllError Case ERROR_ACCESS_DENIED, ERROR_GEN_FAILURE, ERROR_SHARING_VIOLATION, ERROR_SEM_TIMEOUT hFile = 0 End Select Else Call CloseHandle(hFile) hFile = 0 End If If hFile = 0 Then vRet(lCount) = "COM" & lIdx cb.AddItem ("COM" & lIdx) lCount = lCount + 1 End If Next End If If lCount = 0 Then EnumSerialPorts = "" ' Split(vbNullString) Else ReDim Preserve vRet(0 To lCount - 1) As Variant EnumSerialPorts = vRet End If Exit Function EH: PrintError FUNC_NAME Resume Next End FunctionDetails here http://www.ftdichip.com/Support/SoftwareExamples/CodeExamples/VB.htm
I can post some code is anyone is interested.
Bean
I use the propeller tool to create the HUB program and download to the prop. On the prop side I use the SPIN FullDuplexSerial. I use a binary protocol to send and receive data.
Right now I'm looking into a prop loader I can integrate into my C# application.
BTW. the Propellent DLL works well with VS C# and C++