Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old December 15th, 2007, 05:09 AM
tyropitas tyropitas is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 2 tyropitas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 32 m 11 sec
Reputation Power: 0
Assembly - Transfer system

I ve to make a text file transfer system between 2 computers over a serial com.I ve managed to script the transmitter bt i m having difficulties starting the receiver.The proccess for the transmitter is to read the file and then write it on the com port if i m not mistaken.But i can't get around how to start the receiver cause i can't understand the proccess. The receiver should be listening over the port and then?Any pointers on what to do?
Here is the code for my transmitter
Code:
#include <stdio.h>

int main (void) {

 //Define Variables
  char Textfile[] = "C:\\text.txt";   //File that holds the data to transmit
  char Comport[] ="COM2";                   //Define Serial Port
 

  FILE * readfile;
  FILE * writecom;
 

  char error[] = "Unable to open File/Comport\n\n"; //TERMINATION with an error message
  char chartosend;
  char readaccess[] ="r";
  char writeaccess[] ="wt";

  _asm {

//check if the port can be accessed
	  lea eax,writeaccess   //check acess and move it to the stack
	  push eax
	  lea eax,Comport       //check port and move it to the stack
	  push eax

	  call fopen
	  add esp,8   //Clean the stack 

	  cmp eax, 0 
	  mov writecom, eax
	  je TERMINATION //If it doesn't writecom then run TERMINATION for handling errors

//check if textfile is accessible
      lea eax,readaccess  //check for readaccess for the textfile and move it to the stack
	  push eax
	  lea eax, Textfile     //check for textfile and move it to the stack
	  push eax


	  call fopen
	  add esp, 8 //Clean the stack

	  cmp eax, 0
	  mov readfile, eax
	  je TERMINATION    //If it doesn't open readfile then run TERMINATION for handling errors

WHILENOTEOF:
//IF no more data can be read from a data source get each character from the file
     mov eax, readfile
	 push eax

	 call fgetc
	 add esp, 4
	 
//check if EOF has been reached
     cmp al, EOF
	 je FILECLOSE

	 mov chartosend, al

	 push eax
	 add esp, 4
//write characters to comport
	 mov eax, writecom
	 push eax
	 mov al, chartosend
	 push eax
	 call fputc
	 add esp, 8

jmp WHILENOTEOF

FILECLOSE:
//Add closing value to the end of the string
	 mov eax, writecom
	 push eax

	 mov al, 80h  //The receiver needs to know the EOF so closing value is 80h 
	 push eax

	 call fputc
	 add esp,8 

//Start closing
     mov eax, readfile  //readfile
	 push eax

	 call fclose
	 add esp, 4

//writecom
	 mov eax, writecom
	 push eax

	 call fclose
	 add esp, 4

	 jmp END

TERMINATION:
	 lea eax, error
	 push eax

	 call printf
	 add esp, 4

END:
	 } //_asm

	return 0;
	} //void

Thanks

Reply With Quote
  #2  
Old December 16th, 2007, 02:09 PM
coder0xff coder0xff is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: Arizona
Posts: 46 coder0xff User rank is Sergeant (500 - 2000 Reputation Level)coder0xff User rank is Sergeant (500 - 2000 Reputation Level)coder0xff User rank is Sergeant (500 - 2000 Reputation Level)coder0xff User rank is Sergeant (500 - 2000 Reputation Level)coder0xff User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 9 h 27 m 45 sec
Reputation Power: 22
Assuming you are openning the com port as a stream on the receiving computer also, just read from it as you would any stream. Since you are transferring text files, you can have the sender send an EOF character to tell the receiver that the file has ended.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Assembly - Transfer system


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway