Results 1 to 25 of 25

Thread: Send file wia RS232?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Send file wia RS232?

    Hello,
    I have one old cnc machine and need to make software to send created file to CNC machine by RS232 port.
    I know how to make text file and tested it, it works when I send it by original dos version of software by producer.
    Now I need to send it directly from my software.
    I did this for some other kind of cnc machines by sending it as ASCII string.
    But here is different problem.
    File has lot of lines and I don't have any manual from machine, so I don't know how to send it.
    I know parameters of rs232 (com1).
    I used rs232 class downloaded from the web...

    So, problem is that I don't know how to send it...?

    1. Whole file at once

    2. Line by line....

    3...


    Also, format I don't know... I thinks it is ASC (founded some in explanation file, only that), should I convert it to Hex, binary....??



    I tried this (simplified):

    Private ocp As New Rs232
    Private intcomport, intbaud, intdata As Integer
    Private bytstop As Rs232.DataStopBit
    Private bytparity As Rs232.DataParity
    Private buffersize As Integer


    intcomport = 1
    intbaud = 9600
    intdata = 8
    bytparity = Rs232.DataParity.Parity_None
    bytstop = Rs232.DataStopBit.StopBit_1
    buffersize = 4096


    versions to send file
    1.

    Try
    Dim fajl As Byte() = IO.File.ReadAllBytes(Application.StartupPath & "\RTRANSFER.FIL")
    If ocp.IsOpen = False Then
    ocp.Open()

    End If

    ocp.Write(fajl)
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try


    2.

    Try
    Dim fajl As String = ""
    Dim lines As String() = IO.File.ReadAllLines(Application.StartupPath & "\rtransfer.fil")
    For Each line As String In lines
    fajl = fajl & line & vbNewLine
    Next
    If ocp.IsOpen = False Then
    ocp.Open()


    End If


    ocp.Write(fajl)
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try

    3.

    Try
    Dim fajl As String = ""
    If ocp.IsOpen = False Then
    ocp.Open()

    End If


    Dim lines As String() = IO.File.ReadAllLines(Application.StartupPath & "\RTRANSfer.FIL")
    For Each line As String In lines
    ocp.Write(line)
    Next

    Catch ex As Exception
    MsgBox(ex.Message)
    End Try


    Any suggestion what to try..?
    When I send it CNC machine received some kind of data but it is not readable.
    I also att project here.send.zip

    Thank you

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: Send file wia RS232?

    Please format code appropriately for readability. Indenting is important so don't post without it and don't remove leading whitespace from the first line and not others. Use the Alt key while selecting a block of code to be able to remove leading whitespace from the entire block and maintain indenting.
    Code:
        Private ocp As New Rs232
        Private intcomport, intbaud, intdata As Integer
        Private bytstop As Rs232.DataStopBit
        Private bytparity As Rs232.DataParity
        Private buffersize As Integer
    
    
            intcomport = 1
            intbaud = 9600
            intdata = 8
            bytparity = Rs232.DataParity.Parity_None
            bytstop = Rs232.DataStopBit.StopBit_1
            buffersize = 4096
    Code:
            Try
                Dim fajl As Byte() = IO.File.ReadAllBytes(Application.StartupPath & "\RTRANSFER.FIL")
                If ocp.IsOpen = False Then
                    ocp.Open()
    
                End If
    
                ocp.Write(fajl)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    Code:
            Try
                Dim fajl As String = ""
                Dim lines As String() = IO.File.ReadAllLines(Application.StartupPath & "\rtransfer.fil")
                For Each line As String In lines
                    fajl = fajl & line & vbNewLine
                Next
                If ocp.IsOpen = False Then
                    ocp.Open()
    
    
                End If
    
    
                ocp.Write(fajl)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    Code:
            Try
                Dim fajl As String = ""
                If ocp.IsOpen = False Then
                    ocp.Open()
    
                End If
    
    
                Dim lines As String() = IO.File.ReadAllLines(Application.StartupPath & "\RTRANSfer.FIL")
                For Each line As String In lines
                    ocp.Write(line)
                Next
    
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

  3. #3
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: Send file wia RS232?

    If you don't have source or can't decompile the DOS version that works, you either do trial and error like you have been or use some kind of pass-through interface that allows you to see what is being sent back and forth in several different formats. There are hardware versions like I used in the past, but maybe something similar to this free software version would be enough. Once you know what the data format is from both DOS software and CNC, you can design your program to work in the same fashion.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    I have this from decompiler? Is it usable?


    Code:
    void fn3E16_0010(Eq_2 * es)
    {
    	cs->ptr0004 = (char *) es + 0x0010;
    	word16 cx_16 = cs->w0006;
    	struct Eq_11 * ax_13 = (char *) es + 0x0010 + cs->w000C;
    	byte Eq_11::* di_18 = cx_16 - 0x01;
    	byte Eq_5::* si_20 = cx_16 - 0x01;
    	for (; cx_16 != 0x00; --cx_16)
    	{
    		ax_13->*di_18 = cs->*si_20;
    		--si_20;
    		--di_18;
    	}
    }

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    Is it problem that original DOS software is 16, and I am trying with windows 64x?
    An this look that I need to convert string ASCII to hex?

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    Is it problem that original DOS software is 16, and I am trying with windows 64x?
    And this look that I need to convert string ASCII to hex?

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    Tried most of suggestions from net, also recommended ComDebug software. Using this software I receive same data I sent? Is that normal? Also, I don't have a possibility in this software to send file, only string.
    Because CNC machine is actualy DOS system, maybe will work this, I must tried it.

    Code:
    mode COM21 BAUD=115200 PARITY=n DATA=8
    copy yourfile.txt \\.\COM21

  8. #8
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: Send file wia RS232?

    Not sure what to make of what you found in post #4.

    It appears the ComDebug can't be used in the middle of the communications between your PC and CNC, which is what you really need. You might try finding a way to have it simply receive what the DOS program is sending from your PC if your PC has 2 true RS-232 ports. Even Hyperterminal (used to be included with older Windows) might work for that. At least then you would have an idea of what format it is sending the data.

  9. #9
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: Send file wia RS232?

    See if you can get Microsoft's PortMon to work.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    Thank you for your idea. I already tried terminal, some of protocols Xmodem, etc..... Without succes for now. I will try more.

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    I will try PortMon and see.
    Thank you

  12. #12
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: Send file wia RS232?

    This one looks good, too, and has 14-day free trial.

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    Hello,
    Still no progress with this.
    I tried lot of software but without success.

    One situation... I successfuly copied this dos software to my XP Laptop.
    I can run and work with software, but when I tried to send file to CNC Computer there is same message error.
    Is it possible that XP cannot work good with dos com port? I also tried to work on Win10 with usb to com adapter. Same error.

  14. #14
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Send file wia RS232?

    What error message are you getting?

    Since this was DOS, I would expect that the data is ASCII, which would be a string of bytes. The file likely doesn't include line breaks (probably CRLF, though not necessarily), which might have made their way into what you are doing. So, turning the text you want to send into an array of bytes using ASCII encoding seems like a reasonable first step. You also have the the com port settings, so that's taken care of. Sending an array of bytes using the Serial Port class is likely one of the options. Perhaps that is what you are already doing.
    My usual boring signature: Nothing

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    Well, I tried that. I have port settings and I know it must be ASCI.
    Please check att. I have a file for transfer ready and some info from software.

    https://ufile.io/4zskl7p0

  16. #16
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Send file wia RS232?

    Not thrilled with that attachment mechanism. I'm not really in the habit of downloading files from third parties. What is supposed to be in it? If it's an error message, you can just tell us what it is, or attach an image.
    My usual boring signature: Nothing

  17. #17

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    Sorry, something wrong here with att.
    Actually, there is no error, CNC machine is receiving data but cannot use it... there is mess, cannot read it.
    Please check att. Here is also file for transfer.. Original extension is .fil I changed it just because of upload.
    Thanks


    Name:  realterm.jpg
Views: 696
Size:  22.2 KB
    Name:  hyper.jpg
Views: 703
Size:  36.3 KB
    RTRANS.txt

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    Any idea? I am still fighting with this..
    Thanks

  19. #19

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    I think that here problem can be that receiver software is linux based and I am trying to send from windows? How can I be sure that software is Linux? When starting I can see some kind ROM DOS 1.1 message.
    Do I need to do some conversion before sending file because line feed is not same in linux and dos? I tried to send only one single line... Same error. Do I need to add manually LF to the end? Thanks
    Last edited by fikri; Aug 24th, 2019 at 09:29 PM.

  20. #20
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Send file wia RS232?

    If I were doing this, I would hook a computer to the serial port on the receiving side, in place of the CNC machine. Some of the capture software seems like it should work as well, but as a minimum, just catch the raw bytes sent over the serial port.

    It works when you use the DOS program to send the data to the CNC machine, so use the DOS program and send the data, but capture the bytes sent.
    Then compare the bytes sent with the contents of the file.

    It may be likely that the DOS program is parsing the file, and not sending all the contents raw.

  21. #21

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    When I send file by hercul software for sending there are returned first 14 characters from string (first) line....

  22. #22
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Send file wia RS232?

    I would have expected at least 15 characters, and more likely 16 or 17.
    The first line is 15 characters long according to the text file you posted, there is a space in the middle, and I would have thought that one or two characters for the end of line would have also been transmitted.
    But, that does seem to indicate that there isn't parsing being done on the sending side, the file is sent as is, and the ignoring of commented lines and parsing of data lines must all be done on the receiving end.
    Code:
    *LI-FR. 4.67(c)
    *    Testfile RTRANS.FIL - generiert aus den Eingabedaten  
    *    Testfile RTRANS.FIL - generated with data from current data input
    *
    *        LISEC-SOFTWARE       LI-FRAME  Rel: 4.67(c) 
    *
    0001 0333 0333 001 16 0 1          sgsdg                          sdvgsd                                                                                       000 0 00 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 1 0000 1 0000 000 0                              .
    0002 0333 0333 001 16 0 1          sgsdg                          sdvgsd                                                                                       000 0 00 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 1 0000 1 0000 000 0                              .
    In any case, if it only transmitted one line and then stopped, then perhaps the software is waiting for some handshake from the CNC machine when it is ready to receive the next line.

    If that is the case, then your software will probably need to do the same thing. Transmit a line, wait for a handshake, and then continue. Of course, there could be a hardware handshake involved (your DSR/CTS signals), or Software handshake (XOn/XOFF).
    The serial devices I've worked with I didn't need to worry about handshakes, although we did need to add a delay between each line in at least one case when doing file transfers to allow the receiver to process the line before the next one was sent.

    But it seems like your software isn't doing a set delay between lines, as it only transmitted the first line.

    A serial port monitor should allow you to watch the traffic in both directions as you do the transfer with your existing software. I would capture it as a hex byte dump of the data being transmitted, just to be sure of exactly what is being transmitted. You can convert that to text if needed manually. But if you just look at the transfer as text from the start, there could be plenty of non-printable characters that you wouldn't see so you don't have a complete picture of what is going on.

    p.s. I guess it doesn't matter as far as this discussion goes, but until I posted the contents of the file above and noticed the scrollbar at the bottom of the code window, I didn't realize there were more characters on those two data lines further to the right.
    Last edited by passel; Aug 27th, 2019 at 09:55 AM.

  23. #23

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    Yes. You have a right. My mistake, it is 14 character... Last is character c "*LI-FR. 4.67(c"
    However, because I founded some parameters is actual software that handsnake is Nothing, I did not test with it.
    Thank you for idea, tomorrow I will test it with additional parameters.
    PS: File is ok, just need to send it and work is finished. Just this last step.
    Thank you

  24. #24

    Thread Starter
    Junior Member
    Join Date
    Aug 2019
    Posts
    21

    Re: Send file wia RS232?

    Well, tried everything.... Still nothing.
    This situation is confusing me. When I take original software from old dos pc and run it from my laptop and then send file from that software there is same error like when I send it from my software.
    Can it be that COM port on my laptop is different than on original COM port on this old pc?
    I don't know what else can be?

  25. #25
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,392

    Re: Send file wia RS232?

    If the old DOS software is creating the file to send, did you compare the file created on the old DOS PC with the file created on the laptop to make sure that they are exactly the same?

    Did you check the COM port settings on both computers to make sure that they are also exactly the same?

    What you may need if the above checks out is a way to capture exactly what is being sent from both of the computers so you can compare that data and check for differences.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width