Link to home
Create AccountLog in
Visual Basic Classic

Visual Basic Classic

--

Questions

--

Followers

Top Experts

Avatar of burly411
burly411

Receiving via YMODEM
Hi, I'm programming software to dial into a traffic counter and retrieve files from the counter. I am quite familiar with mscomm. The program will dial into the traffic counter and then issue a command to commence the transfer via YMODEM.  It is a binary file I am receiving. Any suggestions on how I can go about this? Thanks.

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of JonyvJonyv


1. Implement the YMODEM protocol yourself, specifications for example at:  http://textfiles.planetmirror.com/programming/FORMATS/
2. Buy a commercial library, for example  http://www.marshallsoft.com/wsc4vb.htm
3. Try to find a free implementation (couldn't find one myself, but I didn't really look that hard...)

good luck!

Avatar of burly411burly411

ASKER

Okay so I am trying to implement the YMODEM protocol on my own. When the sender wishes to send the file they send a null terminated ascii string with the filename. When I use 2 phone lines and connect to a modem with hyperterminal and then use my program to receive the modem buffer I do not receive anything when I choose to send the file on the hyperterminal end. Anything I can do about that? Also with the YMODEM protocol after receiving the filename the receiver (my program) must send an <ack> packet. I am using this code here:
mscomm.output = chr$(6)
Do i need to include the carriage return?
Also if the transfer does start how would i write it to a file. with YMODEM you receive files in 128 or 1024 blocks. Thanks very much.


Well, I'm no guru on serial communication, but I did a quick test at home using two computers connected with nullmodem cable and I was able to receive data via YMODEM in my VB program from the terminal program on the other end.

For some reason I never got any OnComm events from mscomm (perhaps I set it up wrong, haven't really used it very much...), so I used a timer instead and checked if MsComm1.InBufferCount > 0

As this was just a quick test I just set up 3 buttons to be able to send ACK (chr(6)) NAK (chr(21)) and "C".  I then basiclly followed the following sequence from the YMODEM documentation:

SENDER                                                                        RECEIVER
                                                                                          C
SOH 00 FF foo.c NUL[123] CRC CRC
                                                                                        ACK
                                                                                         C
SOH 01 FE Data[128] CRC CRC
                                                                                       ACK
SOH 03 FC Data[128] CRC CRC
                                                                                       ACK
SOH 04 FB Data[100] CPMEOF[28] CRC CRC
                                                                                       ACK
EOT
                                                                                       NAK
EOT
                                                                                      ACK
                                                                                       C
SOH 00 FF NUL[128] CRC CRC
                                                                                      ACK


As you see, before you receive the filename you have to send a "C" character to the sender.  Also note the 3 extra bytes at the beginning of each block. (SOH is chr(1)), the following two bytes i guess is some kind of sequence number.

This is followed by 128 bytes of data followed by 2 bytes of CRC checksum.


This is the code i used in the timer (just prints the data to a text box)

Dim i As Integer
Dim Inp() As Byte

If MSComm1.InBufferCount <> 0 Then
    Inp = MSComm1.Input
    For i = 0 To UBound(Inp)
        Text1.Text = Text1.Text & Chr(Inp(i)) & " "
    Next i
End If

Since you have to save the data to disk you would have to open the file in binary mode an the print each byte with the Put command ( I think it's 'Put' anyway, I don't think I've ever handled binary files in VB  :-)  )

As you might have noticed it's getting a but late here and I feel like I'm just babbling at the moment so I think I will go to sleep now. I hope that at least something of this makes sence to you   :-)

If you need further help, just post again.

Good night!

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Thank you so much. I'll give this a try and see what I can get. I never sent the "C" character so that probably explains alot. Thanks again its greatly appreciated!

Okay so it looks like I can transfer the file and write using FilePut or PutFile *Scratches head* one of the two. I've just got one small concern... the CRC checksums. When the data is coming in and i'm writing it am I writing those extra bytes too? Do i want those extra bytes written? If not how do I make sure that I don't write them. Also I am transferring files at a max of 100kb in size. should I be worried about performing a CRC checksum on them? If so, how would I approach that? I'm sorry that I'm all full of Questions I just want to make sure I'm on the write track. Thank you so much that last post solved alot of confusion over here. I'm just mainly unsure about writing those extra bytes and the checksumming. Thanks :)

So Far my program can

dial in to the traffic counter
find the files that need to be downloaded
download the files (but not write them to a file)
delete the downloaded files
convert the files to be read in the traffic counting software
disconnect

ASKER CERTIFIED SOLUTION
Avatar of JonyvJonyv

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Hey thanks so much for the help. I'm gunna close this question now because I have alot to go with here. If I need anymore I'll just post a new one. Thanks So Much!

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.



 Hi! Jonyv and burly411

 This is the last 6 days of my internship but I couldn't complete my project.In this project I am expected to write a vb code to provide both text and random file transfer between two PC connected via RS232 cable.I have achieved the text file but failed in file transfer.As much as I understood you wrote such a program .I will be very glad If you can send it to me...

shaktar

shaktar@mynet.com
Visual Basic Classic

Visual Basic Classic

--

Questions

--

Followers

Top Experts

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.