C serial com port terminal program

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2007
Posts: 40
Reputation: danibootstrap is an unknown quantity at this point 
Solved Threads: 0
danibootstrap danibootstrap is offline Offline
Light Poster

C serial com port terminal program

 
0
  #1
Mar 6th, 2008
Hello,I have this C program which is equivalent to the com port.Useful for data logging from the sensors.It consists of the .c file and two header files cport.h and xmodem.h .The code compiles fine but there are lot of linker errors.I tried a lot ,pulled my hair but no use.Can anyone help me solve this out.Thanks in advance

comdemo.c
  1. /*
  2. // COMDEMO.C
  3. //
  4. // Serial communications demo program for the Cport communications library.
  5. //
  6. // Copyright (c) 1993 Bri Productions
  7. //
  8. */
  9.  
  10. //#include "E:\robotics\CPORT20\cport.h"
  11. //#include "E:\robotics\CPORT20\xmodem.h"
  12. #include <cport.h>
  13. #include <xmodem.h>
  14. #include <conio.h>
  15. #include <stdlib.h>
  16. #include <dos.h>
  17. #include <bios.h>
  18. #include <ctype.h>
  19. #include <stdio.h>
  20.  
  21.  
  22. /*
  23. //-------------------------------------
  24. //
  25. // Microsoft portability
  26. //
  27. //-------------------------------------
  28. */
  29. #if M_I86
  30.  
  31. #include <stdarg.h>
  32. #include <time.h>
  33. #include <graph.h>
  34.  
  35. #define BLUE 1
  36. #define LIGHTGRAY 7
  37.  
  38. #define bioskey(a) _bios_keybrd(a)
  39. #define gotoxy(x,y) _settextposition((short)(y), (short)(x))
  40. #define clrscr() _clearscreen(_GWINDOW)
  41. #define textattr(a) _settextcolor((short)((a)&0xf)); _setbkcolor((short)((a)>>4))
  42. #define window(a,b,c,d) _settextwindow((short)(b),(short)(a),(short)(d),(short)(c))
  43. #define cputs(s) _outtext(s)
  44.  
  45. int wherex (void);
  46. int wherey (void);
  47. void delay (clock_t milliseconds);
  48. void clreol (void);
  49.  
  50. #endif
  51.  
  52. /*
  53. //-------------------------------------
  54. //
  55. // Queue sizes and thresholds
  56. //
  57. //-------------------------------------
  58. */
  59. #define TXQ 4096
  60. #define RCVQ 4096
  61. #define THRESH (RCVQ * 3 / 4)
  62.  
  63.  
  64. /*
  65. //-------------------------------------
  66. //
  67. // numbers of parameters
  68. //
  69. //-------------------------------------
  70. */
  71. #define NUM_COM 4
  72. #define NUM_BAUD 9
  73. #define NUM_MODE 2
  74. #define NUM_HND 4
  75.  
  76.  
  77. /*
  78. //-------------------------------------
  79. //
  80. // scan codes
  81. //
  82. //-------------------------------------
  83. */
  84. #define A 0x1E00
  85. #define B 0x3000
  86. #define C 0x2E00
  87. #define D 0x2000
  88. #define E 0x1200
  89. #define F 0x2100
  90. #define G 0x2200
  91. #define H 0x2300
  92. #define I 0x1700
  93. #define M 0x3200
  94. #define N 0x3100
  95. #define O 0x1800
  96. #define P 0x1900
  97. #define R 0x1300
  98. #define S 0x1F00
  99. #define W 0x1100
  100. #define X 0x2D00
  101. #define PGDN 0x5100
  102. #define PGUP 0x4900
  103.  
  104.  
  105. #define COM3A PORT2|IRQ5
  106.  
  107.  
  108. /*
  109. //-------------------------------------
  110. //
  111. // text attributes
  112. //
  113. //-------------------------------------
  114. */
  115. #define NORM 0x07
  116. #define BOLD 0x08
  117. #define FAINT 0xF7
  118. #ifndef BLINK
  119. #define BLINK 0x80
  120. #endif
  121. #define REVRS 0x77
  122. #define ESC 0x1b
  123.  
  124.  
  125. /*
  126. //-------------------------------------
  127. //
  128. // parameter constants
  129. //
  130. //-------------------------------------
  131. */
  132. const unsigned id[] = { COM1, COM2, COM3A, COM4 };
  133. const int baud[] = { B115200, B57600, B38400, B19200,
  134. B9600, B4800, B2400, B1200, B300 };
  135. const byte mode[] = { W8|S1|NONE, W7|S1|EVEN };
  136. const byte hndshk[] = { OFF ,SOFT, HARD, HARD|SOFT };
  137.  
  138. /*
  139. //-------------------------------------
  140. //
  141. // parameter indexes
  142. //
  143. //-------------------------------------
  144. */
  145. struct indx{
  146. byte id;
  147. byte baud;
  148. byte mode;
  149. byte ansi;
  150. byte hndshk;
  151. byte lf;
  152. byte echo;
  153. }indx = { 0, 3, 0, 1, 0, 0, 0 };
  154.  
  155.  
  156. /*
  157. //-------------------------------------
  158. //
  159. // parameter messages
  160. //
  161. //-------------------------------------
  162. */
  163. struct{
  164. char *id [NUM_COM ];
  165. char *baud [NUM_BAUD];
  166. char *mode [NUM_MODE];
  167. char *ansi [2];
  168. char *hndshk[NUM_HND];
  169. char *lf [2];
  170. }msg={
  171. { "COM1", "COM2", "COM3", "COM4" },
  172. { "115k", "57600", "38400", "19200", "9600",
  173. "4800", "2400", "1200", "300" },
  174. { "8-1-N", "7-1-E" },
  175. { "TTY", "ANSI" },
  176. { "NONE", "SOFT", "HARD", "BOTH" },
  177. { " ", "LF" }
  178. };
  179.  
  180.  
  181. /*
  182. //-------------------------------------
  183. //
  184. // screen coordinates
  185. //
  186. //-------------------------------------
  187. */
  188. static int x = 1; /* cursor location */
  189. static int y = 1;
  190. static byte attrib = NORM; /* present text attribute */
  191. #define ERR_X 41 /* error message x coordinate */
  192. #define STAT_X 60 /* status message x coordinate */
  193.  
  194.  
  195. /*
  196. //-------------------------------------
  197. //
  198. // function prototypes
  199. //
  200. //-------------------------------------
  201. */
  202. static void Init (void);
  203. static void Uninit (void);
  204. static void NewParam (void);
  205. static void Ansi (void);
  206. static void CheckError (void);
  207. static void CheckStatus (void);
  208. static void Upload (void);
  209. static void Download (void);
  210. static int callback (int msg, unsigned param);
  211. static void put_ch (char c);
  212.  
  213.  
  214.  
  215. char *Xmsg[] = { "\r\ntransfer successful",
  216. "\r\nfile error",
  217. "\r\ntransfer canceled",
  218. "\r\nmemory error"
  219. };
  220.  
  221. struct C_param param;
  222. COM com;
  223.  
  224. /*
  225. //-------------------------------------
  226. //
  227. // main()
  228. //
  229. //-------------------------------------
  230. */
  231. void main(void)
  232. {
  233. char c;
  234. unsigned key;
  235. byte dtr = ON;
  236.  
  237.  
  238. /* initialize */
  239.  
  240. Init();
  241.  
  242. while(1)
  243. {
  244.  
  245. /* Poll the keyboard buffer for available keystrokes. */
  246. /* Meanwhile, the receive queue is checked for available */
  247. /* characters, check for errors and check the modem status */
  248.  
  249. while(!bioskey(1))
  250. {
  251.  
  252. /* If a character(s) is available in the receive queue, */
  253. /* fetch it. If it is and escape character, it must be */
  254. /* check to see if it is the start of an ansi sequence. */
  255. /* Otherwise the cursor position is updated, and the */
  256. /* character is printed. */
  257.  
  258. if(ComLenRx(com))
  259. {
  260. c = ComGetc(com);
  261.  
  262. if(c == ESC && indx.ansi)
  263. {
  264. Ansi();
  265. gotoxy(x, y);
  266. continue;
  267. }
  268.  
  269. put_ch(c);
  270.  
  271. }
  272.  
  273.  
  274. /* Check for errors and changes in the modem status */
  275.  
  276. CheckError();
  277. CheckStatus();
  278. }
  279.  
  280.  
  281. /* When a key is pressed, the key is fetched, and the */
  282. /* keyboard flags are checked to see if the alt key was */
  283. /* also pressed. If the alt key was pressed, we must */
  284. /* check if the key is a valid command, and if so */
  285. /* process it accordingly */
  286.  
  287. key = bioskey(0);
  288. if(!(key & 0x00ff))
  289. {
  290. switch(key)
  291. {
  292.  
  293. /* exit */
  294.  
  295. case X:
  296. Uninit();
  297.  
  298.  
  299. /* Next com port */
  300.  
  301. case C:
  302. ComParam(com, &param);
  303. ComClose(com);
  304. do
  305. {
  306. indx.id++;
  307. indx.id %= NUM_COM;
  308. param.id = id[indx.id];
  309. }
  310. while((com = ComOpenS(&param)) == NULL);
  311. NewParam();
  312. break;
  313.  
  314.  
  315. /* Next baud rate */
  316.  
  317. case B:
  318. indx.baud++;
  319. indx.baud %= NUM_BAUD;
  320. ComBaud(com, baud[indx.baud]);
  321. NewParam();
  322. break;
  323.  
  324.  
  325. /* Next word length */
  326.  
  327. case M:
  328. indx.mode++;
  329. indx.mode %= NUM_MODE;
  330. ComMode(com, mode[indx.mode]);
  331. NewParam();
  332. break;
  333.  
  334.  
  335. /* Toggle ansi terminal */
  336.  
  337. case A:
  338. indx.ansi ^= 1;
  339. NewParam();
  340. break;
  341.  
  342.  
  343. /* Next handshake scheme */
  344.  
  345. case H:
  346. indx.hndshk++;
  347. indx.hndshk %= NUM_HND;
  348. ComHandshake(com, hndshk[indx.hndshk], THRESH);
  349. NewParam();
  350. break;
  351.  
  352.  
  353. /* Echo */
  354.  
  355. case E:
  356. indx.echo ^= 1;
  357. break;
  358.  
  359.  
  360. /* Toggle LF append */
  361.  
  362. case N:
  363. indx.lf ^= 1;
  364. NewParam();
  365. break;
  366.  
  367. /* Initialize hayes modem */
  368.  
  369. case I:
  370. ComPuts(com, "ATZ\r\n");
  371. break;
  372.  
  373.  
  374. /* Hayes modem dial command */
  375.  
  376. case D:
  377. ComPuts(com, "ATDT");
  378. break;
  379.  
  380.  
  381. /* Hayes modem hang up command */
  382.  
  383. case G:
  384. ComPuts(com, "+++");
  385. delay(3000);
  386. ComPuts(com, "ATH0\r\n");
  387. break;
  388.  
  389. case PGUP:
  390. Upload();
  391. break;
  392.  
  393. case PGDN:
  394. Download();
  395. break;
  396.  
  397. case R:
  398. dtr ^= 1;
  399. ComDtr(com, dtr);
  400. break;
  401.  
  402. default:
  403. continue;
  404. }
  405. }
  406.  
  407.  
  408. /* If the key was not a command, put the character in the */
  409. /* transmit queue. If the character is a carriage return, */
  410. /* append a line feed to it just in case. */
  411.  
  412. else
  413. {
  414. ComPutc(com, (char)key);
  415. if(indx.echo)
  416. put_ch((char)key);
  417. CheckStatus();
  418. CheckError();
  419. }
  420. }
  421. }
  422.  
  423.  
  424. /*
  425. //-------------------------------------
  426. //
  427. // Modified putch()
  428. //
  429. //-------------------------------------
  430. */
  431. void put_ch(char c)
  432. {
  433.  
  434. gotoxy(x, y);
  435. putch(c);
  436.  
  437. if(c == '\r' && indx.lf)
  438. putch('\n');
  439.  
  440. if(c == '\b')
  441. printf(" \b");
  442.  
  443. x = wherex();
  444. y = wherey();
  445.  
  446. #ifdef M_I86
  447. if(x == 1 && y == 25)
  448. _scrolltextwindow(1);
  449. #endif
  450. }
  451.  
  452.  
  453. /*
  454. //-------------------------------------
  455. //
  456. // Initialize
  457. //
  458. //-------------------------------------
  459. */
  460. void Init(void)
  461. {
  462. FILE *fp;
  463.  
  464.  
  465.  
  466. /* If an initialization file exists, load it. */
  467.  
  468. fp = fopen("comdemo.ini", "rb");
  469. if(fp)
  470. fread(&indx, sizeof(struct indx), 1, fp);
  471.  
  472.  
  473.  
  474. /* Set up the screen */
  475.  
  476. clrscr();
  477. textattr(BLUE|(LIGHTGRAY<<4));
  478. gotoxy(1,25);
  479. cprintf(" %4s ³%5s %s ³ %-4s ³ %-4s ³ %2s ³"
  480. " no errors ³ CTS= DSR= RI= DCD= ",
  481. msg.id[indx.id],
  482. msg.baud[indx.baud],
  483. msg.mode[indx.mode],
  484. msg.ansi[indx.ansi],
  485. msg.hndshk[indx.hndshk],
  486. msg.lf[indx.lf]);
  487.  
  488.  
  489. /* Initialize the serial port to the default parameters, */
  490. /* set the timeout and set the DTR and RTS lines. */
  491.  
  492. com = ComOpen(id[indx.id], baud[indx.baud], mode[indx.mode], RCVQ, TXQ);
  493.  
  494.  
  495. /* restore the normal screen */
  496.  
  497. textattr(LIGHTGRAY);
  498. window(1,1,80,24);
  499. }
  500.  
  501.  
  502. /*
  503. //-------------------------------------
  504. //
  505. // terminate
  506. //
  507. //-------------------------------------
  508. */
  509. void Uninit(void)
  510. {
  511. FILE *fp;
  512.  
  513.  
  514. /* Store the present parameters in an .ini file so the program */
  515. /* will remember next time it is executed. */
  516.  
  517. fp = fopen("comdemo.ini", "wb");
  518. if(fp)
  519. fwrite(&indx, sizeof(struct indx), 1, fp);
  520.  
  521.  
  522. ComClose(com);
  523. system("cls");
  524. puts("\nÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸"
  525. "\n³ Cport v2.0 - Copyright (c) 1993 Bri Productions ³"
  526. "\nÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´"
  527. "\n³ Bri Productions, P.O. Box 7121, Fremont, CA 94537-7121, USA, (510) 794-0616 ³"
  528. "\nÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;"
  529. );
  530. exit(0);
  531. }
  532.  
  533.  
  534. /*
  535. //-------------------------------------
  536. //
  537. // new parameter
  538. //
  539. //-------------------------------------
  540. */
  541. void NewParam(void)
  542. {
  543.  
  544. /* Update the status line with the new parameters */
  545.  
  546. window(1,25, 80, 25);
  547. textattr(BLUE|(LIGHTGRAY<<4));
  548. cprintf(" %4s ³%5s %s ³ %-4s ³ %-4s ³ %s ³",
  549. msg.id[indx.id],
  550. msg.baud[indx.baud],
  551. msg.mode[indx.mode],
  552. msg.ansi[indx.ansi],
  553. msg.hndshk[indx.hndshk],
  554. msg.lf[indx.lf]);
  555.  
  556.  
  557. /* restore the normal screen */
  558.  
  559. textattr(attrib);
  560. window(1,1,80,24);
  561. gotoxy(x, y);
  562. }
  563.  
  564.  
  565. /*
  566. //-------------------------------------
  567. //
  568. // ansi control sequence
  569. //
  570. //-------------------------------------
  571. */
  572. void Ansi(void)
  573. {
  574. unsigned key;
  575. char c;
  576. char str[10];
  577. int Pn[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  578. int i=0,p=0;
  579. static int oldx=1;
  580. static int oldy=1;
  581.  
  582.  
  583. /* While we are waiting for the next character, keep */
  584. /* checking for keys. */
  585.  
  586.  
  587. while((c = ComGetc(com)) == 0)
  588.  
  589. if(bioskey(1))
  590. {
  591. key = bioskey(0);
  592. ComPutc(com, (char)key);
  593. }
  594.  
  595.  
  596. /* If the next character is a '[' it is probably an ansi */
  597. /* sequence. If the next character is not a '[', print the */
  598. /* previous escape character followed by the new character. */
  599.  
  600. if(c != '[')
  601. {
  602. cprintf("\x1b%c",c);
  603. return;
  604. }
  605.  
  606. while(1)
  607. {
  608.  
  609. /* Read the rest of the ansi sequence, while also checking */
  610. /* for keys. */
  611.  
  612. while((c = ComGetc(com)) == 0)
  613.  
  614. if(bioskey(1))
  615. {
  616. key = bioskey(0);
  617. ComPutc(com, (char)key);
  618. }
  619.  
  620.  
  621. /* If the character is numeric, store it still it it's */
  622. /* ascii form */
  623.  
  624. if(isdigit(c))
  625. {
  626. *(str+i++) = c;
  627. continue;
  628. }
  629.  
  630.  
  631. /* When no more numeric characters are received, terminate */
  632. /* the string and convert it to an integer, storing it in */
  633. /* the parameter queue. */
  634.  
  635. *(str+i) = '\0';
  636. i=0;
  637. Pn[p++] = atoi(str);
  638.  
  639.  
  640. /* Check for the ';' delimiter */
  641.  
  642. if(c == ';')
  643. continue;
  644.  
  645.  
  646. /* When no more numeric parameters are received, the */
  647. /* command should be next. Now we can actually process */
  648. /* the command using the stores parameters */
  649.  
  650. else
  651. {
  652. switch(c)
  653. {
  654.  
  655.  
  656. /* (CUP) set cursor position */
  657.  
  658. case 'H':
  659. case 'F':
  660. y = Pn[0] ? Pn[0] : 1;
  661. x = Pn[1] ? Pn[1] : 1;
  662. return;
  663.  
  664.  
  665. /* (CUU) cursor up */
  666.  
  667. case 'A':
  668. y -= Pn[0];
  669. if(y < 1)
  670. y = 1;
  671. return;
  672.  
  673.  
  674. /* (CUD) cursor down */
  675.  
  676. case 'B':
  677. y += Pn[0];
  678. if(y > 24)
  679. y = 24;
  680. return;
  681.  
  682.  
  683. /* (CUF) cursor forward */
  684.  
  685. case 'C':
  686. x += Pn[0];
  687. if(x >80)
  688. x = 80;
  689. return;
  690.  
  691.  
  692. /* (CUB) cursor backward */
  693.  
  694. case 'D':
  695. x -= Pn[0];
  696. if(x < 1)
  697. x = 1;
  698. return;
  699.  
  700.  
  701. /* (SCP) save cursor position */
  702.  
  703. case 's':
  704. oldx = x;
  705. oldy = y;
  706. return;
  707.  
  708.  
  709. /* (RCP) restore cursor position */
  710.  
  711. case 'u':
  712. x = oldx;
  713. y = oldy;
  714. return;
  715.  
  716.  
  717. /* clear screen */
  718.  
  719. case 'J':
  720. if(Pn[0] == 2)
  721. {
  722. clrscr();
  723. x=1;
  724. y=1;
  725. }
  726. else
  727. {
  728. window(1,wherey(),80,24);
  729. clrscr();
  730. window(1,1,80,24);
  731. gotoxy(x, y);
  732. }
  733. return;
  734.  
  735.  
  736. /* (EL) erase line */
  737.  
  738. case 'K':
  739. clreol();
  740. return;
  741.  
  742.  
  743. /* An attribute command is more elaborate than the */
  744. /* others because it may have many numeric parameters */
  745.  
  746. case 'm':
  747. for(i=0; i<p; i++)
  748. {
  749.  
  750.  
  751. /* values from 30 to 37 define the foreground color */
  752.  
  753. if(Pn[i] >= 30 && Pn[i] <= 37)
  754. {
  755. attrib &= 0xf8;
  756. attrib |= (Pn[i] - 30);
  757. }
  758.  
  759.  
  760. /* values from 40 to 47 define the background color */
  761.  
  762. if(Pn[i] >= 40 && Pn[i] <= 47)
  763. {
  764. attrib &= 0x8f;
  765. attrib |= ((Pn[i] - 40) << 4);
  766. }
  767.  
  768.  
  769. /* values from 0 to 7 define the other attributes */
  770.  
  771. if(Pn[i] >= 0 && Pn[i] <= 7)
  772. switch(Pn[i])
  773. {
  774.  
  775. case 0:
  776. attrib = NORM;
  777. break;
  778.  
  779. case 1:
  780. attrib |= BOLD;
  781. break;
  782.  
  783. case 2:
  784. attrib &= FAINT;
  785. break;
  786.  
  787. case 5:
  788. case 6:
  789. attrib |= BLINK;
  790. break;
  791.  
  792. case 7:
  793. attrib ^= REVRS;
  794. break;
  795.  
  796. default:
  797. attrib = NORM;
  798. }
  799. }
  800.  
  801.  
  802. /* The red and blue bits in the ansi standard are */
  803. /* reversed relative to the IBM. Therefore, before we */
  804. /* set the new attributes, if these bits are in */
  805. /* opposite states toggled. This must be done for */
  806. /* both the foreground and background. */
  807.  
  808. if((attrib & 0x05) == 0x04 || (attrib & 0x05) == 0x01)
  809. attrib ^= 0x05;
  810.  
  811. if((attrib & 0x50) == 0x40 || (attrib & 0x50) == 0x10)
  812. attrib ^= 0x50;
  813.  
  814. textattr(attrib);
  815.  
  816. default:
  817. return;
  818. }
  819. }
  820. }
  821. }
  822.  
  823.  
  824. /*
  825. //-------------------------------------
  826. //
  827. // check for errors
  828. //
  829. //-------------------------------------
  830. */
  831. void CheckError(void)
  832. {
  833. unsigned comerror;
  834. static unsigned last_error = 0;
  835. static int err_flg = 0;
  836. char *errmsg[]= { { "no errors " },
  837. { "break detect " },
  838. { "frame error " },
  839. { "parity error " },
  840. { "overrun " },
  841. { "rx overflow " },
  842. { "tx overflow " }
  843. };
  844.  
  845. comerror = ComError(com);
  846.  
  847.  
  848. /* Check if the error code has changed since the last call. */
  849. /* if it has not, there is no need to update the status line. */
  850. /* If the error code has changed, the error conditions are */
  851. /* checked in the order of their priority */
  852.  
  853. if(comerror != last_error)
  854. {
  855. last_error = comerror;
  856.  
  857. if(comerror & BREAK)
  858. err_flg = 1;
  859.  
  860. else if(comerror & FRAMING)
  861. err_flg = 2;
  862.  
  863. else if(comerror & PARITY)
  864. err_flg = 3;
  865.  
  866. else if(comerror & OVERUN)
  867. err_flg = 4;
  868.  
  869. else if(comerror & RXFULL)
  870. err_flg = 5;
  871.  
  872. else if(comerror & TXFULL)
  873. err_flg = 6;
  874.  
  875. else
  876. err_flg = 0;
  877.  
  878.  
  879. /* Update the status line with the new information */
  880.  
  881. window(1,25, 80, 25);
  882. textattr(BLUE|(LIGHTGRAY<<4));
  883. gotoxy(ERR_X,1);
  884. cprintf(errmsg[err_flg]);
  885.  
  886.  
  887. /* restore the normal screen */
  888.  
  889. textattr(attrib);
  890. window(1,1,80,24);
  891. gotoxy(x, y);
  892. }
  893. }
  894.  
  895.  
  896. /*
  897. //-------------------------------------
  898. //
  899. // check modem status
  900. //
  901. //-------------------------------------
  902. */
  903. void CheckStatus(void)
  904. {
  905. unsigned status;
  906. static unsigned last_status = 1;
  907. int i;
  908.  
  909. status = ComStatus(com);
  910.  
  911.  
  912. /* Check if the modem status has changed since the last call. */
  913. /* if it has not, there is no need to update the status line. */
  914. /* If the modem status has changed, each bit is checked for */
  915. /* it's condition and printed on the status line */
  916.  
  917. if(status != last_status)
  918. {
  919. last_status = status;
  920. window(1,25, 80, 25);
  921. textattr(BLUE|(LIGHTGRAY<<4));
  922.  
  923.  
  924. /* On each iteration, i = the x coordinate in the status */
  925. /* line. The bits are checked for left to right. The */
  926. /* statement !!(status & 0x10) resolves to 1 if the bit */
  927. /* is set or 0 if the bit is clear. By adding 0x30 the */
  928. /* 1 or 0 is converted to an ascii character */
  929.  
  930. for(i=STAT_X; i<STAT_X+6*4; i+=6)
  931. {
  932. gotoxy(i,1);
  933. cprintf("%c", !!(status & 0x10) + 0x30);
  934. status >>= 1;
  935. }
  936.  
  937.  
  938. /* restore the normal screen */
  939.  
  940. textattr(attrib);
  941. window(1,1,80,24);
  942. gotoxy(x, y);
  943. }
  944. }
  945.  
  946.  
  947. /*
  948. //-------------------------------------
  949. //
  950. // Upload a file
  951. //
  952. //-------------------------------------
  953. */
  954. void Upload(void)
  955. {
  956. char filename[83];
  957. int rv;
  958.  
  959. cputs("\r\n");
  960. x = wherex();
  961. y = wherey();
  962.  
  963. *filename = 80;
  964. cputs("File name > ");
  965. cgets(filename);
  966.  
  967. rv = XmodemTx(com, filename + 2, callback);
  968.  
  969. clreol();
  970. cputs(*(Xmsg + rv));
  971.  
  972. cputs("\r\n");
  973. x = wherex();
  974. y = wherey();
  975. }
  976.  
  977.  
  978. /*
  979. //-------------------------------------
  980. //
  981. // Download a file
  982. //
  983. //-------------------------------------
  984. */
  985. void Download(void)
  986. {
  987. char filename[83];
  988. int rv;
  989.  
  990.  
  991. cputs("\r\n");
  992. x = wherex();
  993. y = wherey();
  994.  
  995. *filename = 80;
  996. cputs("File name for your computer > ");
  997. cgets(filename);
  998.  
  999. rv = XmodemRx(com, filename + 2, callback);
  1000.  
  1001. clreol();
  1002. cputs(*(Xmsg + rv));
  1003.  
  1004. cputs("\r\n");
  1005. x = wherex();
  1006. y = wherey();
  1007.  
  1008. }
  1009.  
  1010.  
  1011. /*
  1012. //-------------------------------------
  1013. //
  1014. // Xmodem callback function
  1015. //
  1016. //-------------------------------------
  1017. */
  1018. int callback(int msg, XPARAM param)
  1019. {
  1020. static retry = 10;
  1021. const char *_err_txt;
  1022. static const char *err_txt[] = {
  1023. "OVER RUN",
  1024. "BAD BLOCK",
  1025. "BAD BLOCK CHECK",
  1026. "TIME OUT",
  1027. "TRANSFER CANCELED"
  1028. };
  1029.  
  1030. switch(msg)
  1031. {
  1032. case XM_IDLE:
  1033. break;
  1034.  
  1035. case XM_START:
  1036. cprintf("\r\nWaiting...");
  1037. break;
  1038.  
  1039. case XM_BLOCKCHECK:
  1040. cprintf("\r\nblock check:%s\r\n", param == 0 ? "CHECKSUM" : "CRC");
  1041. break;
  1042.  
  1043. case XM_BLOCK:
  1044. if(retry < 10)
  1045. {
  1046. retry = 10;
  1047. putchar('\n');
  1048. }
  1049. cprintf("\rblock:%d bytes: %ld", param, ((long)param) << 7);
  1050. break;
  1051.  
  1052. case XM_EOT:
  1053. cprintf("\r\nEOT");
  1054. break;
  1055.  
  1056. case XM_DONE:
  1057. break;
  1058.  
  1059. case XM_ERROR:
  1060. if(param & OVERUN)
  1061. _err_txt = err_txt[0];
  1062. else
  1063. _err_txt = err_txt[param >> 12];
  1064. cprintf("\r\nERROR:%s", _err_txt);
  1065. if(retry-- == 0)
  1066. return(1);
  1067. }
  1068.  
  1069. if(kbhit())
  1070. {
  1071. if(getch() == 0x1b)
  1072. return(1);
  1073. }
  1074. return(0);
  1075. }
  1076.  
  1077.  
  1078.  
  1079. /*
  1080. //-------------------------------------
  1081. //
  1082. // Microsoft portability
  1083. //
  1084. //-------------------------------------
  1085. */
  1086. #if M_I86
  1087.  
  1088.  
  1089. int wherex(void)
  1090. {
  1091. byte rv;
  1092.  
  1093. _asm {
  1094. mov bh,0
  1095. mov ah,3
  1096. int 10h
  1097. inc dl
  1098. mov rv,dl
  1099. }
  1100. return(rv);
  1101. }
  1102.  
  1103. int wherey(void)
  1104. {
  1105. byte rv;
  1106.  
  1107. _asm {
  1108. mov bh,0
  1109. mov ah,3
  1110. int 10h
  1111. inc dh
  1112. mov rv,dh
  1113. }
  1114. return(rv);
  1115. }
  1116.  
  1117. void delay (clock_t milliseconds)
  1118. {
  1119. milliseconds += clock();
  1120. while(clock() < milliseconds);
  1121. }
  1122.  
  1123. void clreol(void)
  1124. {
  1125. cprintf("%*c", 80 - wherex() - 1, ' ');
  1126. }
  1127.  
  1128. int cprintf(const char *fmt, ...)
  1129. {
  1130. va_list list;
  1131. int rv;
  1132. char buf[129];
  1133.  
  1134. va_start(list, fmt);
  1135. rv = vsprintf(buf, fmt, list);
  1136. va_end(list);
  1137. _outtext(buf);
  1138. return(rv);
  1139. }
  1140.  
  1141. #endif

And the header files are

cport.h
  1. /*
  2. // CPORT.H
  3. //
  4. // Header file for Cport Communications Library
  5. //
  6. // Copyright (c) 1993 Bri Productions
  7. //
  8. */
  9.  
  10. #ifndef _CPORT_H_
  11. #define _CPORT_H_
  12.  
  13. #include "stddef.h"
  14.  
  15. #if defined __TURBOC__
  16. # if __STDC__
  17. # define _Cdecl
  18. # else
  19. # define _Cdecl cdecl
  20. # endif
  21. #elif defined __ZTC__
  22. # define _Cdecl
  23. #elif defined M_I86 && !defined __ZTC__
  24. # if !defined NO_EXT_KEYS
  25. # define _Cdecl cdecl
  26. # else
  27. # define _Cdecl
  28. # endif
  29. #else
  30. #define _Cdecl
  31. #endif
  32.  
  33.  
  34.  
  35. /*
  36. //-------------------------------------
  37. //
  38. // com port id's
  39. //
  40. //-------------------------------------
  41. */
  42.  
  43. #define PORT0 0x03F8 /* hard port addresses */
  44. #define PORT1 0x02F8
  45. #define PORT2 0x03E8
  46. #define PORT3 0x02E8
  47.  
  48. #define BIOS0 (*(int far *)0x400000l) /* bios port addresses */
  49. #define BIOS1 (*(int far *)0x400002l)
  50. #define BIOS2 (*(int far *)0x400004l)
  51. #define BIOS3 (*(int far *)0x400006l)
  52.  
  53. #define IRQ2 0x2000 /* irq's */
  54. #define IRQ3 0x3000
  55. #define IRQ4 0x4000
  56. #define IRQ5 0x5000
  57. #define IRQ6 0x6000
  58. #define IRQ7 0x7000
  59.  
  60. #define COM1 (PORT0 | IRQ4) /* hard 'com' ports */
  61. #define COM2 (PORT1 | IRQ3)
  62. #define COM3 (PORT2 | IRQ4)
  63. #define COM4 (PORT3 | IRQ3)
  64. /* bios 'com' ports */
  65.  
  66. #define BCOM1 ((BIOS0 | 0x1000) + ((BIOS0 << 4) & 0xf000))
  67. #define BCOM2 ((BIOS1 | 0x1000) + ((BIOS1 << 4) & 0xf000))
  68. #define BCOM3 ((BIOS2 | 0x1000) + ((BIOS2 << 4) & 0xf000))
  69. #define BCOM4 ((BIOS3 | 0x1000) + ((BIOS3 << 4) & 0xf000))
  70.  
  71.  
  72. /*
  73. //-------------------------------------
  74. //
  75. // baud rate divisors
  76. //
  77. //-------------------------------------
  78. */
  79.  
  80. #define B115200 1
  81. #define B57600 2
  82. #define B38400 3
  83. #define B19200 6
  84. #define B9600 12
  85. #define B7200 16
  86. #define B4800 24
  87. #define B3600 32
  88. #define B2400 48
  89. #define B2000 58
  90. #define B1800 64
  91. #define B1200 96
  92. #define B600 192
  93. #define B300 384
  94. #define B150 768
  95. #define B110 1047
  96. #define B75 1536
  97. #define B50 2304
  98.  
  99.  
  100. /*
  101. //-------------------------------------
  102. //
  103. // word lengths
  104. //
  105. //-------------------------------------
  106. */
  107.  
  108. #define W8 3
  109. #define W7 2
  110. #define W6 1
  111. #define W5 0
  112. #define WMASK 3
  113.  
  114.  
  115. /*
  116. //-------------------------------------
  117. //
  118. // stop bits
  119. //
  120. //-------------------------------------
  121. */
  122.  
  123. #define S1 0
  124. #define S2 4
  125. #define SMASK 4
  126.  
  127.  
  128. /*
  129. //-------------------------------------
  130. //
  131. // parity
  132. //
  133. //-------------------------------------
  134. */
  135.  
  136. #define NONE 0x00
  137. #define ODD 0x08
  138. #define EVEN 0x18
  139. #define MARK 0x28
  140. #define SPACE 0x38
  141. #define PMASK 0x38
  142.  
  143.  
  144. /*
  145. //-------------------------------------
  146. //
  147. // handshaking
  148. //
  149. //-------------------------------------
  150. */
  151.  
  152. #define DTR 0x001
  153. #define RTS 0x002
  154. #define S_RX 0x004
  155. #define S_TX 0x008
  156. #define CTS 0x010
  157. #define DSR 0x020
  158. #define DCD 0x080
  159.  
  160. #define SOFT ((S_RX) | (S_TX))
  161. #define HARD ((RTS)| (CTS))
  162. #define HARD1 ((DTR)| (DSR))
  163. #define HARD2 ((RTS)| (CTS))
  164.  
  165.  
  166. /*
  167. //-------------------------------------
  168. //
  169. // error codes
  170. //
  171. //-------------------------------------
  172. */
  173.  
  174. #define OVERUN 0x002 /* overrun error */
  175. #define PARITY 0x004 /* parity error */
  176. #define FRAMING 0x008 /* framing error */
  177. #define BREAK 0x010 /* break detect */
  178. #define RX_FIFO 0x080 /* error in recieve fifo */
  179. #define TXFULL 0x100 /* transmit queue overflow */
  180. #define RXFULL 0x200 /* receive queue overflow */
  181.  
  182.  
  183. /*
  184. //-------------------------------------
  185. //
  186. // status codes
  187. //
  188. //-------------------------------------
  189. */
  190.  
  191. #define DCTS 0x001 /* delta clear to send */
  192. #define DDSR 0x002 /* delta data set ready */
  193. #define TERI 0x004 /* trailing edge ring indicator */
  194. #define DDCD 0x008 /* delta data carrier detect */
  195. #define CTS 0x010 /* clear to send */
  196. #define DSR 0x020 /* data set ready */
  197. #define RI 0x040 /* ring indicator */
  198. #define DCD 0x080 /* data carrier detect */
  199.  
  200. #define S_TX_OFF 0x0100 /* software transmit off */
  201. #define U_TX_OFF 0x0200 /* user transmit off */
  202. #define S_RX_OFF 0x0400 /* software receive off */
  203. #define X_REQST 0x0800 /* send XON/XOFF request */
  204. #define X_SENT 0x1000 /* X character send (TX_DIRECT) */
  205. #define U_TX_DIR 0x2000 /* In direct transmit mode */
  206.  
  207. /*
  208. //-------------------------------------
  209. //
  210. // Uart types ComUart
  211. //
  212. //-------------------------------------
  213. */
  214.  
  215. #define INS8250 1 /* INS8250/INS8250-B */
  216. #define NS16450 2 /* INS8250A/NS16450/NS16C450/NS16C450A */
  217. #define NS16550 3 /* NS16550 */
  218. #define I82510 4 /* 82510 (Intel) */
  219.  
  220.  
  221. /*
  222. //-------------------------------------
  223. //
  224. // ComTurbo options
  225. //
  226. //-------------------------------------
  227. */
  228.  
  229. #define TIMER 0x01 /* timer bit (irq0) */
  230. #define KEYBOARD 0x02 /* keyboard bit (irq1) */
  231. #define CASCADE 0x04 /* cascade/reserved bit (irq2) */
  232.  
  233.  
  234. /*
  235. //-------------------------------------
  236. //
  237. // NS16550 rx FIFO trigger levels
  238. //
  239. //-------------------------------------
  240. */
  241.  
  242. #define T550_1 0x00
  243. #define T550_4 0x40
  244. #define T550_8 0x80
  245. #define T550_14 0xC0
  246.  
  247.  
  248. /*
  249. //-------------------------------------
  250. //
  251. //
  252. //
  253. //-------------------------------------
  254. */
  255.  
  256. /*
  257. //-------------------------------------
  258. //
  259. // typedefs and structures
  260. //
  261. //-------------------------------------
  262. */
  263.  
  264. #ifndef _BYTE_
  265. #define _BYTE_
  266. typedef unsigned char byte;
  267. #endif
  268.  
  269. /* Make sure this structure is byte packed
  270. */
  271.  
  272. #ifdef M_I86
  273. #pragma pack(1)
  274. #endif
  275.  
  276. /** Do not change this structure **/
  277.  
  278. struct C_param{
  279. unsigned id; /* com port id */
  280. int baud; /* baud rate */
  281. byte mode; /* word length, stop bits, parity */
  282. unsigned rxQ; /* receive queue size */
  283. unsigned txQ; /* transmit queue size */
  284. byte htype; /* handshaking type */
  285. unsigned thresh; /* handshaking threshold (rx queue) */
  286. };
  287.  
  288. typedef struct C_param CPARAM;
  289. typedef void* COM;
  290.  
  291. #ifdef M_I86
  292. #pragma pack()
  293. #endif
  294.  
  295. /*
  296. //-------------------------------------
  297. //
  298. // Misc
  299. //
  300. //-------------------------------------
  301. */
  302.  
  303. enum { OFF , ON };
  304. #define TX_DIRECT 0x20
  305.  
  306.  
  307. /*
  308. //-------------------------------------
  309. //
  310. // comopen_errno
  311. //
  312. //-------------------------------------
  313. */
  314.  
  315. #define NO_ERR 0 /* no error */
  316. #define OPENED 1 /* port already opened */
  317. #define BAD_ID 2 /* bad id parameter */
  318. #define NO_UART 3 /* no uart chip found */
  319. #define RX_ALC 4 /* receive queue allocation error */
  320. #define TX_ALC 5 /* transmit queue allocation error */
  321. #define MAX_PORT 6 /* max number of com ports opened */
  322. #define IRQ_CTN 7 /* interrupt contention */
  323. #define GEN_ALC 8 /* general allocation error */
  324.  
  325.  
  326. /*
  327. //-------------------------------------
  328. //
  329. // function macros
  330. //
  331. //-------------------------------------
  332. */
  333.  
  334. #define ComOut1(c,a) ComMcr(c,a, 0x04)
  335. #define ComRts(c,a) ComMcr(c,a, 0x02)
  336. #define ComDtr(c,a) ComMcr(c,a, 0x01)
  337.  
  338.  
  339. /*
  340. //-------------------------------------
  341. //
  342. // function prototypes
  343. //
  344. //-------------------------------------
  345. */
  346.  
  347. #ifdef __cplusplus
  348. extern "C" {
  349. #endif
  350.  
  351. /* control functions */
  352.  
  353. COM _Cdecl ComOpen (unsigned id, int baud, byte mode, unsigned rxQ, unsigned txQ);
  354. COM _Cdecl ComOpenS (const CPARAM* param);
  355. COM _Cdecl ComClose (COM com);
  356. void _Cdecl ComHandshake (COM com, byte htype, unsigned thresh);
  357. void _Cdecl ComParam (COM com, CPARAM* param);
  358. void _Cdecl ComBaud (COM com, int baud);
  359. void _Cdecl ComMode (COM com, byte mode);
  360. int _Cdecl ComTx (COM com, int cmnd);
  361. void _Cdecl ComTurbo (int options);
  362. void _Cdecl ComCloseAll (void);
  363. void _Cdecl ComNS550 (COM com, int trigger);
  364. unsigned _Cdecl ComRxQ (COM com, unsigned size);
  365. unsigned _Cdecl ComTxQ (COM com, unsigned size);
  366.  
  367.  
  368. /* input functions */
  369.  
  370. char _Cdecl ComGetc (COM com);
  371. unsigned _Cdecl ComLenRx (COM com);
  372. char *_Cdecl ComGets (COM com, char *str, int maxc, char termc);
  373. unsigned _Cdecl ComIn (COM com, void *abyte, unsigned nbyte);
  374. void _Cdecl ComFlushRx (COM com);
  375. char _Cdecl ComPeek (COM com);
  376. unsigned _Cdecl ComRxScan (COM com, char c);
  377.  
  378.  
  379. /* output functions */
  380.  
  381. int _Cdecl ComPutc (COM com, char c);
  382. unsigned _Cdecl ComLenTx (COM com);
  383. int _Cdecl ComPuts (COM com, const char *str);
  384. unsigned _Cdecl ComOut (COM com, const void *abyte, unsigned nbyte);
  385. void _Cdecl ComFlushTx (COM com);
  386. void _Cdecl ComTxWait (COM com);
  387.  
  388.  
  389. /* status functions */
  390.  
  391. void _Cdecl ComMcr (COM com, byte on_off, byte bits);
  392. unsigned _Cdecl ComError (COM com);
  393. unsigned _Cdecl ComStatus (COM com);
  394. int _Cdecl ComUart (COM com);
  395.  
  396.  
  397. /* misc fuctions */
  398.  
  399. void _Cdecl ComSetBreak (COM com);
  400. void _Cdecl ComClrBreak (COM com);
  401. void _Cdecl ComPutScrtch (COM com, byte abyte);
  402. byte _Cdecl ComGetScrtch (COM com);
  403.  
  404.  
  405. /* data integrity functions */
  406.  
  407. byte _Cdecl ComChecksum (const void *abyte, unsigned nbyte);
  408. unsigned _Cdecl ComCrc16 (const void *abyte, unsigned nbyte);
  409. unsigned long _Cdecl ComCrc32 (const void *abyte, unsigned nbyte);
  410.  
  411.  
  412. /* debug */
  413.  
  414. COM _Cdecl ComHandle (COM com);
  415.  
  416.  
  417. #ifdef __cplusplus
  418. } /* extern "C" */
  419. #endif
  420.  
  421.  
  422.  
  423. /*
  424. //-------------------------------------
  425. //
  426. // comopen_errno
  427. //
  428. //-------------------------------------
  429. */
  430.  
  431.  
  432. #ifdef __cplusplus
  433. extern "C" int comopen_errno;
  434. #else
  435. extern int comopen_errno;
  436. #endif
  437.  
  438.  
  439.  
  440. /*
  441. //-------------------------------------
  442. //
  443. // Other header files
  444. //
  445. //-------------------------------------
  446. */
  447.  
  448. /* Implicit and explicit C++ inclusion
  449.   */
  450. #ifdef __cplusplus
  451. #include "cport.hpp"
  452. #endif
  453.  
  454.  
  455. /* Xmodem inclusion
  456.   */
  457. #ifdef Uses_Xmodem
  458. #include "xmodem.h"
  459. #endif
  460.  
  461. /* Zmodem inclusion
  462.   */
  463. #ifdef Uses_Zmodem
  464. #include "zmodem.h" /* Not yet implemented */
  465. #endif
  466.  
  467.  
  468. #endif /* CPORT.H */

xmodem.h header file
  1. /*
  2. // XMODEM.H
  3. //
  4. // Header file for Xmodem file transfer protocol
  5. //
  6. // Copyright (c) 1993 Bri Productions
  7. //
  8. */
  9.  
  10.  
  11. #ifndef _XMODEM_H_
  12. #define _XMODEM_H_
  13.  
  14. /*
  15. //-------------------------------------
  16. //
  17. // additional callback() error codes
  18. //
  19. // ( lower 12 bits == ComError() )
  20. //
  21. //-------------------------------------
  22. */
  23. #define XE_BADBLOCK 0x1000 /* Bad block */
  24. #define XE_BADCHECK 0x2000 /* Bad block check */
  25. #define XE_TIMEOUT 0x3000 /* Timeout */
  26. #define XE_CANCEL 0x4000 /* Canceled */
  27.  
  28.  
  29. /*
  30. //-------------------------------------
  31. //
  32. // Return codes
  33. //
  34. //-------------------------------------
  35. */
  36. enum {
  37. XR_NOERR, /* No error */
  38. XR_FILEERR, /* File error */
  39. XR_CANCEL, /* Transfer canceled */
  40. XR_ALLOC, /* Memory allocation */
  41. XR_USER /* Start of user return codes */
  42. };
  43.  
  44. /*
  45. //-------------------------------------
  46. //
  47. // callback messages
  48. //
  49. //-------------------------------------
  50. */
  51. enum {
  52. XM_IDLE, /* Idle time */
  53. XM_START, /* Starting transfer */
  54. XM_BLOCKCHECK, /* Type of block check */
  55. XM_BLOCK, /* New block */
  56. XM_EOT, /* End of transmission */
  57. XM_DONE, /* Transmission complete */
  58. XM_ERROR /* Error */
  59. };
  60.  
  61. /*
  62. //-------------------------------------
  63. //
  64. // callback messages parameter
  65. //
  66. //-------------------------------------
  67. */
  68. typedef unsigned XPARAM;
  69.  
  70.  
  71.  
  72.  
  73. /*
  74. //-------------------------------------
  75. //
  76. // Function prototypes
  77. //
  78. //-------------------------------------
  79. */
  80.  
  81. #ifdef __cplusplus
  82. extern "C" {
  83. #endif
  84.  
  85. int _Cdecl XmodemTx(COM com, const char* file, int (*cb)(int msg, XPARAM param));
  86. int _Cdecl XmodemRx(COM com, const char* file, int (*cb)(int msg, XPARAM param));
  87. int _Cdecl Xcallback(int msg, XPARAM param);
  88.  
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92.  
  93. #endif /* XMODEM.H */

I am getting the following linker errors (I compiled this in turbo c++ windows)
Linker error : Undefined symbol _ComOpenS
Linker error : Undefined symbol _ComGets
.....
and 16 such errors.What is the problem with the code ..I am n ot able to understand
Last edited by Ancient Dragon; Mar 6th, 2008 at 1:28 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,431
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1471
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: C serial com port terminal program

 
0
  #2
Mar 6th, 2008
what compiler and os?
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 40
Reputation: danibootstrap is an unknown quantity at this point 
Solved Threads: 0
danibootstrap danibootstrap is offline Offline
Light Poster

Re: C serial com port terminal program

 
0
  #3
Mar 6th, 2008
Originally Posted by Ancient Dragon View Post
what compiler and os?
I am Using Turbo C 3.0 under Windows Xp
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 40
Reputation: danibootstrap is an unknown quantity at this point 
Solved Threads: 0
danibootstrap danibootstrap is offline Offline
Light Poster

Re: C serial com port terminal program

 
0
  #4
Mar 6th, 2008
Originally Posted by Ancient Dragon View Post
what compiler and os?
Also ancient dragon could you please re-format the first post .I mean you there are two header files cport.h and xmodem.h along with the comdemo.c file
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,431
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1471
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: C serial com port terminal program

 
0
  #5
Mar 6th, 2008
Originally Posted by danibootstrap View Post
Also ancient dragon could you please re-format the first post .I mean you there are two header files cport.h and xmodem.h along with the comdemo.c file
done
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,431
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1471
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: C serial com port terminal program

 
0
  #6
Mar 6th, 2008
I don't have your compiler so I probably can't help very much. Link errors means that you have not include one or more libraries in your project.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 40
Reputation: danibootstrap is an unknown quantity at this point 
Solved Threads: 0
danibootstrap danibootstrap is offline Offline
Light Poster

Re: C serial com port terminal program

 
0
  #7
Mar 6th, 2008
the following is the link to download the files.What I understand is that the cports.lib should be linked .How shall I like this to the comdemo.c file .Also how shall I create project file in Turbo C++ 3.0
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 40
Reputation: danibootstrap is an unknown quantity at this point 
Solved Threads: 0
danibootstrap danibootstrap is offline Offline
Light Poster

Re: C serial com port terminal program

 
0
  #8
Mar 6th, 2008
Solved now...It was with linking the lib file...Problem is different compilers have different ways of linking
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC