Announcement

Collapse
No announcement yet.

Parsing a serial byte?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Parsing a serial byte?

    I am using PowerBasic Console Compiler5 to receive some data from a serial port. The data is actually a set of 8 bits, each of which represents a bit of hardware data. Apparently PowerBasic can only receive data from a serial port as a character. The debugger shows the value of a typical character as "<03>". I am trying to decode the character to obtain the original bits. I have tried VAL and I have tried parsing the character using a MID statement, but no joy.

    Does anyone know how I can obtain the original bit data?

  • #2
    You can test a bit with a logical AND, or check the BIT function.

    Bye!
    -- The universe tends toward maximum irony. Don't push it.

    File Extension Seeker - Metasearch engine for file extensions / file types
    Online TrID file identifier | TrIDLib - Identify thousands of file formats

    Comment


    • #3
      Terry, you can use:
      Code:
      #COMPILE EXE
      #DIM ALL
      
      FUNCTION PBMAIN () AS LONG
          LOCAL sb AS STRING, bb AS BYTE
          sb = CHR$(23)
          bb = 23
          ? BIN$(CVBYT(sb), 8)
          ? BIN$(bb, 8)
          WAITKEY$
      
      END FUNCTION
      Last edited by John Gleason; 26 May 2009, 12:13 PM. Reason: added WAITKEY$

      Comment


      • #4
        Serial Port

        I am not sure how PBCC handles Serial Ports (maybe I should check into it more)

        That aside, what is the piece of hardware that you are communicating with? (Communication parameters change depending on the device)

        Engineer's Motto: If it aint broke take it apart and fix it

        "If at 1st you don't succeed... call it version 1.0"

        "Half of Programming is coding"....."The other 90% is DEBUGGING"

        "Document my code????" .... "WHYYY??? do you think they call it CODE? "

        Comment


        • #5
          Parsing serial data

          The device that I am communicating with is a DLP-USB245M-G which allows 8-bit hardware data to be read by a computer via a USB cable. FTDI's VCP (Virtual COM Port) drivers allow the PC to see the data as though it was connected to a COM (RS-232) port. I have a microcontroller project with data that I want to place in a log file on the PC. I also want to display information encoded in the data on the screen.

          John Gleason provided me with the statement that I had overlooked, CVBYT, which will convert the string data to a numeric form.

          Thanks to all who replied!

          Terry

          Comment

          Working...
          X