For DOS Protected Mode version of sensor core software
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

591 lines
15 KiB

3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: Comm485.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of Comm485.cpp
  13. //----------------------------------------------------------------------------
  14. #include <dos.h>
  15. #include <stdio.h>
  16. #include "..\lgs\comm485.h"
  17. //#include "..\LgLib\version.h"
  18. #include <dpmi.h>
  19. #include <go32.h>
  20. static __dpmi_regs callback_regs;
  21. static _go32_dpmi_seginfo callback_info;
  22. int install_real_mode_service_handler( void (*func)( __dpmi_regs * ) ){
  23. __dpmi_regs r;
  24. callback_info.pm_offset = (long)func;
  25. callback_info.pm_selector = _my_cs();
  26. /* Replace the next line with the equivalent *_iret function if your real-mode service requires it. */
  27. if( _go32_dpmi_allocate_real_mode_callback_retf( &callback_info, &callback_regs ) ) return -1;
  28. /* Fill all the required fields of the '__dpmi_regs' with appropriate values including
  29. the interrupt function number. In the next example the ES:DX register pair
  30. was used as a pointer to the handler. Feel free to modify as necessary. */
  31. r.x.es = callback_info.rm_segment;
  32. r.x.dx = callback_info.rm_offset;
  33. /* Finally call the required interrupt. */
  34. //__dpmi_int( interrupt_number, &r );
  35. return 0;
  36. };
  37. #include <sys/nearptr.h>
  38. #include <crt0.h>
  39. void * MK_FP (unsigned short seg, unsigned short ofs){
  40. if ( !(_crt0_startup_flags & _CRT0_FLAG_NEARPTR) )
  41. if (!__djgpp_nearptr_enable ())
  42. return (void *)0;
  43. return (void *) (seg*16 + ofs + __djgpp_conventional_base);
  44. };
  45. //extern bool g_bIsVortex;
  46. /*!
  47. Gets value of BIOS timer counter (1/18 of second)
  48. */
  49. //static DWORD far* g_Timer = (DWORD far*)0x46CL;
  50. //#ifdef INCLUDE_WINDOWS_DEFINITIONS
  51. // #define TIMER() *g_Timer
  52. //#else
  53. // #define TIMER() (GetTickCount() * 10 / 182)
  54. //#endif
  55. const uint8_t CComm485::c_acPort[] = {0x04, 0x03, 0x04, 0x03};//IRQ instead of ISR //{0x0C, 0x0B, 0x0C, 0x0B};
  56. const uint8_t CComm485::c_acMask[] = {0xEF, 0xF7, 0xEF, 0xF7};
  57. CComm485::CComm485():
  58. #ifndef COMM_WITHOUT_INTERRUPTS
  59. CIsr(),
  60. #endif
  61. CConnection(){
  62. m_pBaseAddress = 0;
  63. #ifndef COMM_WITHOUT_INTERRUPTS
  64. m_bFollowControlTimer = true;
  65. mbValidableFCT = false;
  66. #endif
  67. m_nBase = 0;
  68. #ifdef __DJGPP__
  69. memset( &m_OldIsrProc, 0, sizeof(__dpmi_paddr));
  70. memset( &m_CurrentIsrProc, 0, sizeof(__dpmi_paddr));
  71. #else
  72. m_pOldIsrProc = NULL;
  73. #endif
  74. #ifdef COMM_RS485_PREVENT_ECHO
  75. m_bWrite = false;
  76. #endif
  77. m_nBaudRate = 0;
  78. m_nBitCount = 0;
  79. m_eParity = _NOPARITY;
  80. #ifdef DEBUG_SHOW_COMMUNICATION
  81. m_bShowCommunication = false;
  82. m_nShowCommunicationWrite = 0;
  83. m_nShowCommunicationRead = 0;
  84. m_bShowCommunicationWritten = false;
  85. #endif
  86. }
  87. CComm485::~CComm485()
  88. {
  89. Destroy();
  90. }
  91. #ifndef COMM_WITHOUT_INTERRUPTS
  92. void CComm485::SetFCT( bool bFCT ){
  93. m_bFollowControlTimer = bFCT;
  94. };
  95. #endif
  96. bool CComm485::SetParameters( int32_t nBaudRate, int16_t nBitCount, PARITY eParity )
  97. {
  98. if( !m_pBaseAddress )
  99. return false;
  100. if( m_nBaudRate == nBaudRate && m_nBitCount == nBitCount && m_eParity == eParity )
  101. return true;
  102. // finish transmition!!!
  103. Flush();
  104. // prepare configuration
  105. int config;
  106. switch( nBitCount )
  107. {
  108. case 5: config = LCR_SERIALDB5; break;
  109. case 6: config = LCR_SERIALDB6; break;
  110. case 7: config = LCR_SERIALDB7; break;
  111. case 8: config = LCR_SERIALDB8; break;
  112. default:
  113. return false;
  114. }
  115. // add parity
  116. config |= (uint8_t)eParity;
  117. // Setup baud rate;
  118. outportb( m_pBaseAddress + LCR_REGISTER, LCR_DLAB );
  119. // remember baudrate for future use
  120. m_nBaudRate = nBaudRate;
  121. m_nBitCount = nBitCount;
  122. m_eParity = eParity;
  123. // initialize baudrate generator
  124. outportb( m_pBaseAddress + DLL_REGISTER,
  125. static_cast<uint8_t> (115200L / nBaudRate) );
  126. outportb( m_pBaseAddress + DLM_REGISTER, 0 );
  127. // Setup configuration
  128. outportb( m_pBaseAddress + LCR_REGISTER, config );
  129. return true;
  130. }
  131. bool CComm485::Create( PORTS nPort, int32_t nBaudRate, int16_t nBitCount, PARITY eParity ){
  132. Destroy();
  133. if( !m_InputStream.Create() ) return false;
  134. if( !m_OutputStream.Create() ) return false;
  135. m_nBase = nPort;
  136. m_pBaseAddress = *((short far*)MK_FP(0x0040, 2 * m_nBase ));
  137. if(!m_pBaseAddress){
  138. #ifdef DEBUG
  139. printf( "COM%d: is Inaccessable\n", nPort+1 );
  140. #endif
  141. return false;
  142. #ifdef DEBUG
  143. } else {
  144. printf( "COM%d: is Accessable\n", nPort+1 );
  145. #endif
  146. };
  147. //(_farpeekb (_dos_ds, 0x0047b) & 0x20)
  148. _farpeekb ( _dos_ds, 0x00400 + 2*m_nBase );
  149. /*
  150. int config;
  151. switch( nBitCount )
  152. {
  153. case 5: config = LCR_SERIALDB5; break;
  154. case 6: config = LCR_SERIALDB6; break;
  155. case 7: config = LCR_SERIALDB7; break;
  156. case 8: config = LCR_SERIALDB8; break;
  157. default:
  158. return false;
  159. }
  160. // Setup baud rate;
  161. outportb( m_pBaseAddress + LCR_REGISTER, LCR_DLAB );
  162. // remember baudrate for future use
  163. m_nBaudRate = nBaudRate;
  164. outportb(m_pBaseAddress + DLL_REGISTER,
  165. static_cast<uint8_t> (115200L / nBaudRate));
  166. outportb( m_pBaseAddress + DLM_REGISTER, 0 );
  167. // Setup configuration
  168. outportb( m_pBaseAddress + LCR_REGISTER, config );
  169. */
  170. #ifdef DEBUG
  171. printf("Set Com Parameters\n");
  172. #endif
  173. if( !SetParameters( nBaudRate, nBitCount, eParity ) )
  174. return false;
  175. // Use FIFO
  176. outportb( m_pBaseAddress + FCR_REGISTER, FCR_ITL14 | FCR_RESETTF | FCR_RESETRF | FCR_FIFO_ENABLE );
  177. #ifndef COMM_WITHOUT_INTERRUPTS
  178. // First thing is to store the old interrupt
  179. //m_pOldIsrProc = _dos_getvect( c_acPort[m_nBase] );
  180. //_dos_setvect( c_acPort[m_nBase], m_pIsrProc );
  181. // Set OUT2 bit to enable interrupts
  182. outportb( m_pBaseAddress + MCR_REGISTER, MCR_IE );
  183. // Enable the interrupts we want
  184. outportb( m_pBaseAddress + IER_REGISTER, IER_EDSSI | IER_ELSI | IER_ERBFI );
  185. // Last thing to do is unmask the int in the ICU --> moved to ISR class
  186. //outportb( IMR_REGISTER, c_acMask[m_nBase] & inp(IMR_REGISTER) );
  187. initISR( c_acPort[m_nBase] );
  188. #else
  189. // Disable all interrupts
  190. outportb( m_pBaseAddress + IER_REGISTER, 0 );
  191. #endif
  192. SetRTS( false );
  193. // clear RTS
  194. // uint8_t MCR_Status = inportb( m_pBaseAddress + MCR_REGISTER );
  195. // if( MCR_Status & MCR_RTSC )
  196. // outportb( m_pBaseAddress + MCR_REGISTER, MCR_Status & ~MCR_RTSC );
  197. #ifdef DEBUG
  198. printf( "Done Creating COM port\n" );
  199. #endif
  200. return true;
  201. }
  202. void CComm485::Flush()
  203. {
  204. #ifdef COMM_WITHOUT_INTERRUPTS
  205. while( !Validate() );
  206. #else
  207. // output remaining bytes
  208. while( m_OutputStream.GetCount() );
  209. // wait until output shift register become empty
  210. while( !(inportb(m_pBaseAddress + LSR_REGISTER) & LSR_TEMPT) );
  211. #endif
  212. }
  213. void CComm485::Destroy()
  214. {
  215. if( m_pBaseAddress )
  216. {
  217. // finish transmition!!!
  218. Flush();
  219. // Disable FIFO
  220. outportb(m_pBaseAddress + FCR_REGISTER, 0);
  221. #ifndef COMM_WITHOUT_INTERRUPTS
  222. // Disable interrupt
  223. outportb(m_pBaseAddress + MCR_REGISTER, 0);
  224. outportb(m_pBaseAddress + IER_REGISTER, 0);
  225. // disable in interrupt controller -> moved to ISR resign
  226. //outportb(IMR_A_REGISTER, ~c_acMask[m_nBase] | inp(IMR_REGISTER));
  227. // return old vector
  228. //_dos_setvect(c_acPort[m_nBase], m_pOldIsrProc );
  229. resignISR();
  230. #endif
  231. m_pBaseAddress = 0;
  232. #ifdef COMM_RS485_PREVENT_ECHO
  233. m_bWrite = false;
  234. #endif
  235. m_nBase = 0;
  236. }
  237. m_nBaudRate = 0;
  238. m_nBitCount = 0;
  239. m_eParity = _NOPARITY;
  240. }
  241. #ifndef COMM_WITHOUT_INTERRUPTS
  242. void CComm485::OnISR(){
  243. // First thing to do in interrupt routines is tell
  244. // the ICU about the service being done. This avoids lock-up
  245. // outportb( ICR_REGISTER, END_OF_INTERRUPT );
  246. while( true ){
  247. uint8_t byte;
  248. int LSR_Status;
  249. int IIR_Status = inportb( m_pBaseAddress + IIR_REGISTER );
  250. if( IIR_Status & IIR_PENDING )
  251. break;
  252. IIR_Status &= IIR_INTERRUPT_MASK; // Equal 0x0F
  253. switch( IIR_Status )
  254. {
  255. case IIR_BREAK_OR_ERROR:
  256. // In order of priority
  257. // It's just important to read the LSR_REGISTER
  258. LSR_Status = inportb(m_pBaseAddress + LSR_REGISTER);
  259. if( LSR_Status & LSR_ERROR_MASK )
  260. {
  261. // read error byte from receiver buffer
  262. inportb(m_pBaseAddress + RBR_REGISTER);
  263. }
  264. break;
  265. case IIR_RECEIVER_READY:
  266. case IIR_TIMEOUT:
  267. while( true )
  268. {
  269. // read byte from receiver buffer
  270. byte = inportb(m_pBaseAddress + RBR_REGISTER);
  271. #ifdef COMM_RS485_PREVENT_ECHO
  272. // check for echo
  273. if( !m_bWrite )
  274. #endif
  275. m_InputStream.Put( byte );
  276. // Check when receiver data ready
  277. LSR_Status = inportb(m_pBaseAddress + LSR_REGISTER);
  278. if(!(LSR_Status & LSR_DR))
  279. break;
  280. }
  281. break;
  282. case IIR_TRANSMITER_EMPTY:
  283. // if there are not bytes for transmit
  284. if( !m_OutputStream.GetCount() )
  285. {
  286. #ifdef COMM_RS485_PREVENT_ECHO
  287. // check for echo
  288. m_bWrite = false;
  289. #endif
  290. /*if( !( inportb(m_pBaseAddress + LSR_REGISTER) & LSR_THRE ) )
  291. break;
  292. if( !( inportb(m_pBaseAddress + LSR_REGISTER) & LSR_TEMPT ) )
  293. break;
  294. */
  295. // m_nBaudRate m_nBitCount m_eParity
  296. if ( m_bFollowControlTimer ){
  297. // if( getTimerCC() > ( 2 * 65536L/m_nBaudRate ) ){
  298. setTimerCC( (unsigned long) ( 2 * 65536L/m_nBaudRate ) ); //( m_nBitCount+2 ) );
  299. mbValidableFCT = true;
  300. // };
  301. break;
  302. } else {
  303. SetRTS( false );
  304. };
  305. // clear RTS
  306. // uint8_t MCR_Status = inportb( m_pBaseAddress + MCR_REGISTER );
  307. // if( MCR_Status & MCR_RTSC )
  308. // outportb( m_pBaseAddress + MCR_REGISTER, MCR_Status & ~MCR_RTSC );
  309. // enable receiver and disable transmitter
  310. outportb(m_pBaseAddress + IER_REGISTER,
  311. IER_EDSSI | IER_ELSI | IER_ERBFI );
  312. break;
  313. }
  314. #ifdef COMM_RS485_PREVENT_ECHO
  315. // check for echo
  316. m_bWrite = true;
  317. #endif
  318. // while there are bytes in output stream
  319. while(1){
  320. // check for transmitter buffer overflow
  321. LSR_Status = inportb(m_pBaseAddress + LSR_REGISTER);
  322. if(!(LSR_Status & LSR_THRE))
  323. break;
  324. // get new byte for transmit
  325. if( !m_OutputStream.Get( &byte ) )
  326. break;
  327. // write byte into FIFO
  328. outportb(m_pBaseAddress + THR_REGISTER, byte );
  329. }
  330. break;
  331. case IIR_MODEM_CHANGE_STATUS:
  332. // Must read the MSR_REGISTER or will lock up the system!
  333. inportb(m_pBaseAddress + MSR_REGISTER);
  334. break;
  335. }
  336. }
  337. }
  338. #endif // ! COMM_WITHOUT_INTERRUPTS
  339. #ifdef COMM_WITHOUT_INTERRUPTS
  340. bool CComm485::Validate(){
  341. uint8_t byte;
  342. if( !m_pBaseAddress ) return true;
  343. // check errors
  344. // while( inportb(m_pBaseAddress + LSR_REGISTER) & LSR_ERROR_MASK )
  345. while( inportb(m_pBaseAddress + LSR_REGISTER) & ( LSR_FIFOE | LSR_FE | LSR_PE | LSR_OE ) )
  346. {
  347. // read error byte from receiver buffer
  348. inportb(m_pBaseAddress + RBR_REGISTER);
  349. }
  350. // check receiver
  351. while( inportb(m_pBaseAddress + LSR_REGISTER) & LSR_DR )
  352. {
  353. // read byte from receiver buffer
  354. byte = inportb(m_pBaseAddress + RBR_REGISTER);
  355. #ifdef COMM_RS485_PREVENT_ECHO
  356. // check for echo
  357. if( !m_bWrite )
  358. #endif
  359. m_InputStream.Put( byte );
  360. }
  361. // if there are not bytes for transmit
  362. if( m_OutputStream.GetCount() )
  363. {
  364. // set RTS
  365. SetRTS( true );
  366. // uint8_t MCR_Status = inportb( m_pBaseAddress + MCR_REGISTER );
  367. // if( !(MCR_Status & MCR_RTSC) )
  368. // outportb( m_pBaseAddress + MCR_REGISTER, MCR_Status | MCR_RTSC );
  369. #ifdef COMM_RS485_PREVENT_ECHO
  370. // check for echo
  371. m_bWrite = false;
  372. #endif
  373. // if FIFO empty
  374. if( inportb(m_pBaseAddress + LSR_REGISTER) & LSR_THRE )
  375. {
  376. // while there are bytes in output stream
  377. for( int16_t i = 0; i < 16; i++ )
  378. {
  379. // get new byte for transmit
  380. if( !m_OutputStream.Get( &byte ) )
  381. break;
  382. // write byte into FIFO
  383. outportb(m_pBaseAddress + THR_REGISTER, byte );
  384. }
  385. }
  386. }
  387. // check for transmit end
  388. if( !( inportb(m_pBaseAddress + LSR_REGISTER) & LSR_THRE ) ) return false;
  389. if( !( inportb(m_pBaseAddress + LSR_REGISTER) & LSR_TEMPT ) ) return false;
  390. SetRTS( false );
  391. // clear RTS
  392. // uint8_t MCR_Status = inportb( m_pBaseAddress + MCR_REGISTER );
  393. // if( MCR_Status & MCR_RTSC )
  394. // outportb( m_pBaseAddress + MCR_REGISTER, MCR_Status & ~MCR_RTSC );
  395. #ifdef COMM_RS485_PREVENT_ECHO
  396. // check for echo
  397. m_bWrite = false;
  398. #endif
  399. if( m_OutputStream.GetCount() ) return false;
  400. return true;
  401. }
  402. #else // COMM_WITHOUT_INTERRUPTS
  403. bool CComm485::ValidateRTS(){
  404. if( mbValidableFCT ){
  405. if( !( inportb(m_pBaseAddress + LSR_REGISTER) & LSR_THRE ) )
  406. return false;
  407. if( !( inportb(m_pBaseAddress + LSR_REGISTER) & LSR_TEMPT ) )
  408. return false;
  409. SetRTS( false );
  410. mbValidableFCT = false;
  411. };
  412. return true;
  413. }
  414. #endif //COMM_WITHOUT_INTERRUPTS
  415. DWORD CComm485::Write( IN PBYTE pBuffer, IN DWORD dwSize, IN DWORD dwTimeout )
  416. {
  417. // unused parameter
  418. dwTimeout;
  419. int16_t nWritten = 0;
  420. nWritten = m_OutputStream.Put( pBuffer, dwSize ); // Direct Write to the port
  421. #ifdef DEBUG_SHOW_COMMUNICATION
  422. if( m_bShowCommunication )
  423. {
  424. printf( "\nW%d: ", m_nShowCommunicationWrite++ );
  425. for( DWORD i = 0; i < nWritten; i++ )
  426. printf( "%02X", (uint8_t)pBuffer[i] );
  427. m_bShowCommunicationWritten = true;
  428. }
  429. #endif
  430. #ifndef COMM_WITHOUT_INTERRUPTS
  431. SetRTS( true );
  432. // set RTS
  433. // uint8_t MCR_Status = inportb( m_pBaseAddress + MCR_REGISTER );
  434. // if( !(MCR_Status & MCR_RTSC) )
  435. // outportb( m_pBaseAddress + MCR_REGISTER, MCR_Status | MCR_RTSC );
  436. // enable transmitter and disable receiver
  437. outportb(m_pBaseAddress + IER_REGISTER,
  438. IER_EDSSI | IER_ELSI | IER_ETBEI | IER_ERBFI );
  439. #endif
  440. return nWritten;
  441. }
  442. DWORD CComm485::ReadWithWait( IN PBYTE pBuffer, IN DWORD dwSize, IN DWORD dwTimeout ){
  443. DWORD dwRead = 0;
  444. DWORD dwCount = 0;
  445. DWORD dwSTIME = TIMER();
  446. while( ( dwCount < dwSize ) && ( ( TIMER() - dwSTIME ) < dwTimeout ) ){
  447. dwCount = m_InputStream.Get( pBuffer+dwRead, dwSize-dwRead );
  448. dwRead += dwCount;
  449. };
  450. return dwRead;
  451. };
  452. DWORD CComm485::Read( IN PBYTE pBuffer, IN DWORD dwSize, IN DWORD dwTimeout ){
  453. // unused parameter
  454. dwTimeout;
  455. DWORD dwRead = 0;
  456. dwRead = m_InputStream.Get( pBuffer, dwSize );
  457. #ifdef DEBUG_SHOW_COMMUNICATION
  458. if( m_bShowCommunication )
  459. {
  460. if( dwRead && m_bShowCommunicationWritten )
  461. {
  462. printf( "\nR%d: ", m_nShowCommunicationRead++ );
  463. m_bShowCommunicationWritten = false;
  464. }
  465. for( DWORD i = 0; i < dwRead; i++ )
  466. printf( "%02X", (uint8_t)pBuffer[i] );
  467. }
  468. #endif
  469. // read bytes from receive stream
  470. return dwRead;
  471. }
  472. bool CComm485::SetRTS( bool bOn )
  473. {
  474. // set/clear RTS
  475. uint8_t MCR_Status = inportb( m_pBaseAddress + MCR_REGISTER );
  476. if( bOn ) {
  477. //putch(37);//%
  478. if( !(MCR_Status & MCR_RTSC) ) outportb( m_pBaseAddress + MCR_REGISTER, MCR_Status | MCR_RTSC );
  479. } else {
  480. //putch(36);//$
  481. if( MCR_Status & MCR_RTSC ) outportb( m_pBaseAddress + MCR_REGISTER, MCR_Status & ~MCR_RTSC );
  482. };
  483. return bOn;
  484. }
  485. bool CComm485::SetDTR( bool bOn )
  486. {
  487. // set/clear DTR
  488. uint8_t MCR_Status = inportb( m_pBaseAddress + MCR_REGISTER );
  489. if( bOn ) {
  490. //putch(35);//#
  491. if( !(MCR_Status & MCR_DTRC) ) outportb( m_pBaseAddress + MCR_REGISTER, MCR_Status | MCR_DTRC );
  492. } else {
  493. //putch(33);//!
  494. if( MCR_Status & MCR_DTRC ) outportb( m_pBaseAddress + MCR_REGISTER, MCR_Status & ~MCR_DTRC );
  495. };
  496. return bOn;
  497. };