Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Socket Programming

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

    Socket Programming

    have USB device that "Talks" to software running on my machine. I want to be able to read this data and then do a lookup on a DBF and then display relevant information.

    What I have found out so far:

    The socket outputs the messages on IP "127.0.0.1" socket 30003 in a CSV format, with a carriage return and lifefeed (ascii 13 followed by ascii 10) at the end of each message.

    Not all lines will have the same number of fields, and not all fields will have the same meaning. Basically, the first field has the message type, and then from that I know how many other fields there will be and what they will contain.

    I want to ignore any message types that aren't ones I want.

    the records I want to read are formatted as shown below:

    Field 1: AIR
    Field 2: [null]
    Field 3: SessionID
    Field 4: AircraftID
    Field 5: HexIdent
    Field 6: FlightID
    Field 7: Date message generated
    Field 8: Time message generated
    Field 9: Date message logged
    Field 10: Time message logged


    I then want to do a database lookup on field 5 [HexIdent].

    Can some tell me whether this is available in A5V7 as I see some "socket" commands. If so how do I go about doing it.

    open socket.
    if field1 = "AIR" get Field5

    query on HexIdent field [24-bit-binary code represented in 6 character Hex].

    display result.

    go back to reading the socket for next query.
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

    #2
    Re: Socket Programming

    Graham,

    In the Alpha Five helpfile I read:
    Syntax: <SOCKETS> as P = SOCKETS.OPEN( Hostname as C, Port as N, Mode as C [, ConnectTimeout as N ] )

    Description
    <SOCKETS> A pointer to the open connection.

    Hostname: The hostname or IP address of the remote host to connect to, such as "www.alphasoftware.com".

    Port: The TCP/IP port to open the connection on.

    Mode: The socket mode:

    "C" = Client; "S" = Server; "L" = Listener

    ConnectTimeout: Optional. The time-out period in milliseconds.

    Description
    The SOCKETS.OPEN() method establishes an Internet connection. The method creates a blocking call, which means that the system will be unresponsive until either the socket is successfully opened or ConnectTimeout milliseconds have elapsed.

    "C" and "S" mode socket open calls are blocking. This means that a client or server socket open call will not return until the connection is successfully established or the connection attempt is aborted by the operating system. This can cause Alpha Five to appear to be hung while a connection is being established, as the operating system timeout period is typically 8 minutes.

    ConnectTimeout, if specified, is the time in milliseconds to wait before aborting the connection attempt and allows the operating system timeout to be overridden.

    In your case:

    Code:
    <SOCKETS> as P = SOCKETS.OPEN("127.0.0.1", 30003, "L", 10000 )
    and of course all the other sockets commands such as <SOCKETS>.READLINE() etc. There are simple examples in the helpfile.

    I don't know for sure but the other device might miss data if you tap on the 30003 port.

    Regards,

    Marcel
    Last edited by Marcel Kollenaar; 09-05-2006, 09:14 AM.
    Marcel

    I hear and I forget. I see and I remember. I do and I understand.
    ---- Confusius ----

    Comment


      #3
      Re: Socket Programming

      Thanks Marcel,

      I assume I dont need to setup a server for this one off project?
      --
      Support your local Search and Rescue Unit, Get Lost!

      www.westrowops.co.uk

      Comment


        #4
        Re: Socket Programming

        Graham,

        That's a very good question. :) I honestly don't know but with the next simple test I think you can use the commands without setting up an server.

        Code:
        dim sock as P
        sock = sockets.open("127.0.0.1",80,"L",1000)
        
        ?sock.close()
        = <No data returned>
        I didn't get errors that I need a server or anythings else. I suspect the USB is the server and your program that uses the data is the client.

        With the <sockets>.peek(1024) command you can look at the first 1024 bytes of data without removing them. The problem is to get the socket address that already is opend by the client program. If you open a socket on the same ip and port I think you will get an error. I did when I opened the same ip a second time...

        At the moment I deduct common knowledge. Maybe some Guru from Alpha can help you further.
        Marcel

        I hear and I forget. I see and I remember. I do and I understand.
        ---- Confusius ----

        Comment


          #5
          Re: Socket Programming

          I tried a simple test using socket.open() but it needs to have the socket to itself, does not want to play, says socket already in use. This being the case, I have come across a PHP script than CAN share the socket and read data, so I think I will have to self teach myself some php to be able to modify this script to achieve my aims, not that I have ever programmed in PHP either!!
          thanks for your time.
          --
          Support your local Search and Rescue Unit, Get Lost!

          www.westrowops.co.uk

          Comment


            #6
            Re: Socket Programming

            ;)
            Marcel

            I hear and I forget. I see and I remember. I do and I understand.
            ---- Confusius ----

            Comment


              #7
              Re: Socket Programming

              It sounds like your USB device is acting as a server on the socket, which is the expected behavior. In that case, you should be opening the socket in Alpha as a client socket using the "C" flag.

              Lenny Forziati
              Vice President, Internet Products and Technical Services
              Alpha Software Corporation

              Comment


                #8
                Re: Socket Programming

                Hello Graham;

                What type of USB device are you using? I'm wanting to use a USB connection to a Glucometer to grab data from it to create possibly an imported CSV or DBF file, which I can then manipulate and append into the A5 application. I'm wondering if this might work.

                Would the SOCKETS functions achieve this? Have you had success with your device?

                Very interested to find out your results!

                regards, awj :)



                Originally posted by Graham Wickens
                have USB device that "Talks" to software running on my machine. I want to be able to read this data and then do a lookup on a DBF and then display relevant information.

                What I have found out so far:

                The socket outputs the messages on IP "127.0.0.1" socket 30003 in a CSV format, with a carriage return and lifefeed (ascii 13 followed by ascii 10) at the end of each message.

                Not all lines will have the same number of fields, and not all fields will have the same meaning. Basically, the first field has the message type, and then from that I know how many other fields there will be and what they will contain.

                I want to ignore any message types that aren't ones I want.

                the records I want to read are formatted as shown below:

                Field 1: AIR
                Field 2: [null]
                Field 3: SessionID
                Field 4: AircraftID
                Field 5: HexIdent
                Field 6: FlightID
                Field 7: Date message generated
                Field 8: Time message generated
                Field 9: Date message logged
                Field 10: Time message logged


                I then want to do a database lookup on field 5 [HexIdent].

                Can some tell me whether this is available in A5V7 as I see some "socket" commands. If so how do I go about doing it.

                open socket.
                if field1 = "AIR" get Field5

                query on HexIdent field [24-bit-binary code represented in 6 character Hex].

                display result.

                go back to reading the socket for next query.

                Comment


                  #9
                  Re: Socket Programming

                  Sorry Andrew,

                  I cant help, programming sockets and stuff is all new to me, so cannot really help you.
                  --
                  Support your local Search and Rescue Unit, Get Lost!

                  www.westrowops.co.uk

                  Comment


                    #10
                    Re: Socket Programming

                    Originally posted by awj
                    Hello Graham;

                    What type of USB device are you using? I'm wanting to use a USB connection to a Glucometer to grab data from it to create possibly an imported CSV or DBF file, which I can then manipulate and append into the A5 application. I'm wondering if this might work.

                    Would the SOCKETS functions achieve this? Have you had success with your device?

                    Very interested to find out your results!

                    regards, awj :)
                    Hello awj,

                    I don't know if this reply will help you but I recently bought a little device with an USB connection. The smart part of it is that the vendor of the USB chip made a driver in such way that someone can access the USB port as an COM port. Virtual COM port (VCP) drivers cause the USB device to appear as an additional COM port available to the PC. Application software can access the USB device in the same way as it would access a standard COM port.

                    This is remarkable because if you programmed all your software to communicate with a serial com device you don't have to reprogram all your software for USB. Problem is that not every supplier of USB (hardware) chips have this kind of driver type; a virtual driver or a dll version that can be accessed by API-calls and in both cases in range of Alpha Five.

                    The other way around is also possible. e.g. You have a normal serial device and has the next connection.

                    Code:
                    PC->COM1<--->serial->hardware
                    If you have hardware with a serial interface you only have to add this chip to create a USB version of it. The only thing it does is:

                    Code:
                    PC->VCOM->USB<--->USB->serial->hardware
                    I don't know if you can get the hardware specs of this gluco device and try to find out the manufacturer/vendor. If it is your own and dare to open it you can write down the IC type and number and look around on the net if the manufacturer has virtual drivers for it or a legacy dll.

                    However there is one catch. In this case USB is just a kind of "host-connection". Behind the USB chip in the device everything is serial again.
                    Last edited by Marcel Kollenaar; 09-10-2006, 03:23 PM.
                    Marcel

                    I hear and I forget. I see and I remember. I do and I understand.
                    ---- Confusius ----

                    Comment


                      #11
                      Re: Socket Programming

                      Hello Marcel;

                      Can we access this "COM Port" with Alpha Five somehow if I had a VCP driver?

                      thx, awj

                      Comment


                        #12
                        Re: Socket Programming

                        Originally posted by awj
                        Hello Marcel
                        Can we access this "COM Port" with Alpha Five somehow if I had a VCP driver?

                        thx, awj
                        Yes, to the outside world it just looks like a normal COM port. I've seen posts here that there is an ActiveX software package to do the serial communication. This should do the job if you have such virtual driver. But the point is to see if the vendor of the USB schip in the gluco device has such driver for it. Each USB chip is different and there is no such thing as a general driver that covers all. The only vendor up till now is FTDI.

                        The chip in the device I bought is an FT232BL


                        Very important! The drivers on the FTDI site are only usable with the chips FTDI produces. You have to look at the vendors site of the chip that your device uses.

                        BTW In the next upcomming weeks or month (depends on how much time I can spend on this subject) I'm planning to try to communicate with an network device with A5 datagrams (UDP net message, I think) and have to use sockets. If there is something to mention I will :).
                        Last edited by Marcel Kollenaar; 09-10-2006, 04:41 PM.
                        Marcel

                        I hear and I forget. I see and I remember. I do and I understand.
                        ---- Confusius ----

                        Comment


                          #13
                          Re: Socket Programming

                          awj,

                          I read some of your older posts. Is it correct that these post did not solve your problem? And if so what is the real problem?

                          I'll start a new topic....
                          Marcel

                          I hear and I forget. I see and I remember. I do and I understand.
                          ---- Confusius ----

                          Comment


                            #14
                            Re: Socket Programming

                            Hello Marcel,

                            finally got the code to read the data coming from socket 30003:

                            Code:
                            dim bs as p = sockets.open("127.0.0.",30003,"C")
                            dim bsOutput as c
                            for i = 1 to 10
                            bsOutput = bs.readline()
                            trace.writeln(bsOutput)
                            next I
                            That is the easy part, Now I have to workout how to continually listen to the port and do the database lookups at the same time.
                            Last edited by Graham Wickens; 01-03-2007, 05:22 AM. Reason: Correction to Xbasic Code
                            --
                            Support your local Search and Rescue Unit, Get Lost!

                            www.westrowops.co.uk

                            Comment


                              #15
                              Re: Socket Programming

                              Thanks Graham for the feedback! :)
                              Marcel

                              I hear and I forget. I see and I remember. I do and I understand.
                              ---- Confusius ----

                              Comment

                              Working...
                              X