locked
small basic serial port send/receive sample RRS feed

  • Question

  • I made a sample program for RS232C communication to get current data from a datalogger.
    Firstly I wrote as this.  " Cur1=CommPort.RXall() ". But program stopped. 
    So I changed it as follows.  It works well.  
     Please tell me Why  "CommPort.RXall()" does not work well? Please forgive my poor English.
     '  RS232C  27CH Current DataLogger Program
    ' for HIOKI E.E. Corp. Hilogger 8422
    
    
    CommPort.OpenPort("COM3",9600) 
     
    RS_Data_Enter()
    
    
    Sub RS_Data_Enter     
     deli13=Text.GetCharacter(13)
     deli10=Text.GetCharacter(10)
     deli= deli13+deli10         ' 
      
     Commport.TXString(":MEMORY:GETREAL"+deli) 'Real Time Data 
    
      FOR RSI=1 TO  27     '27Ch
       Send_MSG=text.Append(":MEMORY:VREAL? CH",RSI)+deli
       CommPort.TXString(Send_MSG)
        Cur=""
       
       DO_Loop:
          Cur1=CommPort.RXChar()     '1 Char input  
           If Cur1=deli10 then
             Goto End_DLP
           EndIf
          Cur=text.Append(Cur,Cur1) 
         Goto DO_Loop   
     
       End_DLP: 
        Cur=math.ABS(Math.Floor(Cur))
        Current=text.Right(text.Append("   ",Cur),6) ''
         Cur27=text.Append(Cur27,Current)
      EndFor 
    
       TextWindow.WriteLine(Cur27)
        
    Endsub  
    
     

    Monday, June 20, 2011 8:29 AM
    Answerer

Answers

  • The history of this extension is that it was originally created by Nino Carrillo in an earlier version of SmallBasic and then unsupported. At one stage I rebuilt it for newer versions of SmallBasic (extensions must be rebuilt with each SB version) and have done so since.

    See this thread and some earlier ones for more on its history.

    The current compiled extension and C# source (VS2010 Express project) can be found here.

    Looking at the code, all this function does is return the .Net method ReadExisting() of a SerialPort object - perhaps debug the extension source - if you want help with this then ask - first you will need to be able to compile the extension source.


    • Proposed as answer by litdev Tuesday, June 28, 2011 7:16 PM
    • Marked as answer by litdev Saturday, July 9, 2011 9:41 AM
    Monday, June 20, 2011 3:40 PM

All replies

  • Hi,

    SmallBasic does not support serial port communication without an extension.  In cases like yours, it usually helps to identify the extension you are using (or simply ask the author of the extension directly).

    Regards,
    --Brian

    Monday, June 20, 2011 11:27 AM
  • Just out of curiosity, what ports does Small Basic support? Thanks! 

     

                                                                               --- jc0976

    Monday, June 20, 2011 12:47 PM
  • The history of this extension is that it was originally created by Nino Carrillo in an earlier version of SmallBasic and then unsupported. At one stage I rebuilt it for newer versions of SmallBasic (extensions must be rebuilt with each SB version) and have done so since.

    See this thread and some earlier ones for more on its history.

    The current compiled extension and C# source (VS2010 Express project) can be found here.

    Looking at the code, all this function does is return the .Net method ReadExisting() of a SerialPort object - perhaps debug the extension source - if you want help with this then ask - first you will need to be able to compile the extension source.


    • Proposed as answer by litdev Tuesday, June 28, 2011 7:16 PM
    • Marked as answer by litdev Saturday, July 9, 2011 9:41 AM
    Monday, June 20, 2011 3:40 PM