|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
UART0 receive problemHi All, I need a help, basically I want to tap the I/O line between a smart card and smart card reader. For this I am using JNUT board 1.3H, where I want to connect the UART0 Rx line to the above mentioned I/O line. What is the extra circuitry I need to Tap this I/O line. Is it sufficient to connect the I/O line from smart card via a pull up resistor to the Rx pin of UART0? Or there is a level shifter is required? Smart card also works in the +5V, Please help me I am confused in this. Regards Prasad _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: UART0 receive problemPrasad.Nagapati@... wrote:
> I need a help, basically I want to tap the I/O line between a smart > card and smart card reader. > > For this I am using JNUT board 1.3H, where I want to connect the UART0 > Rx line to the above mentioned I/O line. > > What is the extra circuitry I need to Tap this I/O line. > > Is it sufficient to connect the I/O line from smart card via a pull up > resistor to the Rx pin of UART0? Or there is a level shifter is > required? > > Smart card also works in the +5V, If the smart card interface is 5V then you simply connect expansion port pin 39. And, of course, GND (pins 5, 6, 7 or 8). First problem: You need to remove R18, otherwise the RX output of IC6 will work against your smart card and one of them will become damaged sooner or later. This is an intentionally larger SMD resistor, so it shouldn't be too difficult to remove it. Second problem: Needless to say that, after removing R18, your receiver at the DB-9 is gone. Third problem: When programming the board, you need to remove the new connection at pin 39. Otherwise programming will fail. To avoid all these problems, why not use UART1 and connect the smart card to expansion port pin 57? Here's the expansion port layout http://www.ethernut.de/en/hardware/enut1/ports.html (Do not mount R33! This is for UART1 routed to the DB-9 only.) For the software use NutRegisterDevice(&DEV_UART1, 0, 0); fp = fopen(DEV_UART1_NAME, "r+"); fread(fp,....); The big advantage is, that you don't need to modify the hardware and UART0 at the DB-9 connector is still available. Harald _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: UART0 receive problemThank You Harald,
As you said I will use the UART1 only, sorry to say this I don't know why I have forgotten there is a second UART in the board :-( Will try with this and check. Regards Prasad -----Original Message----- From: en-nut-discussion-bounces@... [mailto:en-nut-discussion-bounces@...] On Behalf Of Harald Kipp Sent: Wednesday, June 10, 2009 11:02 PM To: Ethernut User Chat (English) Subject: Re: [En-Nut-Discussion] UART0 receive problem Prasad.Nagapati@... wrote: > I need a help, basically I want to tap the I/O line between a smart > card and smart card reader. > > For this I am using JNUT board 1.3H, where I want to connect the UART0 > Rx line to the above mentioned I/O line. > > What is the extra circuitry I need to Tap this I/O line. > > Is it sufficient to connect the I/O line from smart card via a pull up > resistor to the Rx pin of UART0? Or there is a level shifter is > required? > > Smart card also works in the +5V, If the smart card interface is 5V then you simply connect expansion port pin 39. And, of course, GND (pins 5, 6, 7 or 8). First problem: You need to remove R18, otherwise the RX output of IC6 will work against your smart card and one of them will become damaged sooner or later. This is an intentionally larger SMD resistor, so it shouldn't be too difficult to remove it. Second problem: Needless to say that, after removing R18, your receiver at the DB-9 is gone. Third problem: When programming the board, you need to remove the new connection at pin 39. Otherwise programming will fail. To avoid all these problems, why not use UART1 and connect the smart card to expansion port pin 57? Here's the expansion port layout http://www.ethernut.de/en/hardware/enut1/ports.html (Do not mount R33! This is for UART1 routed to the DB-9 only.) For the software use NutRegisterDevice(&DEV_UART1, 0, 0); fp = fopen(DEV_UART1_NAME, "r+"); fread(fp,....); The big advantage is, that you don't need to modify the hardware and UART0 at the DB-9 connector is still available. Harald _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: UART0 receive problemHi Harald, As you mentioned I am using UART1 now, and connected it to directly the smart card I/O line which operates at +5V. Smart card settings are 9600, 8 data bit, Even parity, 1 stop bit. Even I configured the same in my code also. But I am getting random data, what could be the reason, do I need an inverter before connecting to the Rx of UART1? Please help me regarding this. Sample code below /* * Sniffer code sample. */ int main(void) { int got; int i; u_long baud = 9600; unsigned char parity = 2; // even parity unsigned char stopBit = 1; // 1 stop bit FILE *uart; FILE *uart1; TCPSOCKET *sock; u_char mac[6] = { 0x00, 0x06, 0x98, 0x00, 0x00, 0x55 }; /* UART0*/ NutRegisterDevice(&DEV_UART, 0, 0); uart = fopen(DEV_UART_NAME, "r+"); _ioctl(_fileno(uart), UART_SETSPEED, &baud); _ioctl(_fileno(uart), UART_SETPARITY , &parity); _ioctl(_fileno(uart), UART_SETSTOPBITS, &stopBit); /*UART1 */ NutRegisterDevice(&DEV_UART1, 0, 0); uart1 = fopen(DEV_UART1_NAME, "r+"); _ioctl(_fileno(uart1), UART_SETSPEED, &baud); _ioctl(_fileno(uart1), UART_SETPARITY , &parity); _ioctl(_fileno(uart1), UART_SETSTOPBITS, &stopBit); /* ETHERNUT */ NutRegisterDevice(&DEV_ETHER, 0x8300, 5); NutNetLoadConfig(DEV_ETHER_NAME); memcpy(confnet.cdn_mac, mac, 6); NutNetSaveConfig(); /* * Setup the ethernet device. Try DHCP first. If this is * the first time boot with empty EEPROM and no DHCP server * was found, use hardcoded values. */ if (NutDhcpIfConfig("eth0", 0, 60000)) { if (NutDhcpIfConfig("eth0", mac, 60000)) { u_long ip_addr = inet_addr("192.168.192.100"); u_long ip_mask = inet_addr("255.255.255.0"); NutNetIfConfig("eth0", mac, ip_addr, ip_mask); /* If not in a local network, we must also call NutIpRouteAdd() to configure the routing. */ } } fprintf(uart,"IP: %s\n", inet_ntoa(confnet.cdn_ip_addr)); /* * The low level function read() will grab all available bytes * from the input buffer. If the buffer is empty, the call will * block until something is available for reading. */ /* * Create a socket. */ if ((sock = NutTcpCreateSocket()) != 0) { /* * Listen on port 23. If we return, we got a client. */ if (NutTcpAccept(sock, 23) == 0) { /* * Open a stream and associate it with the socket, so * we can use standard I/O. Note, that socket streams * currently do support text mode. */ if ((stream = _fdopen((int) sock, "r+b")) != 0) { /* * Send a welcome banner. */ fputs_P(banner_P, stream); /* * Flush output and read a line. */ fflush(stream); for (i = 0;; i++) { int i; got = _read(_fileno(uart1), inbuf, sizeof(inbuf)); fprintf(stream,"bytes read %d\r\n",got); for(i=0;i<got;i++) { fprintf(stream,"\nrecieved char is %x",inbuf[i]); } fprintf(stream,"\r\n"); } } } } /* * Nut/OS never expects a thread to return. So we enter an * endless loop here. */ /* * Close our socket. */ NutTcpCloseSocket(sock); while(1); } Regards Prasad -----Original Message----- From: en-nut-discussion-bounces@... [mailto:en-nut-discussion-bounces@...] On Behalf Of Harald Kipp Sent: Wednesday, June 10, 2009 11:02 PM To: Ethernut User Chat (English) Subject: Re: [En-Nut-Discussion] UART0 receive problem Prasad.Nagapati@... wrote: > I need a help, basically I want to tap the I/O line between a smart > card and smart card reader. > > For this I am using JNUT board 1.3H, where I want to connect the UART0 > Rx line to the above mentioned I/O line. > > What is the extra circuitry I need to Tap this I/O line. > > Is it sufficient to connect the I/O line from smart card via a pull up > resistor to the Rx pin of UART0? Or there is a level shifter is > required? > > Smart card also works in the +5V, If the smart card interface is 5V then you simply connect expansion port pin 39. And, of course, GND (pins 5, 6, 7 or 8). First problem: You need to remove R18, otherwise the RX output of IC6 will work against your smart card and one of them will become damaged sooner or later. This is an intentionally larger SMD resistor, so it shouldn't be too difficult to remove it. Second problem: Needless to say that, after removing R18, your receiver at the DB-9 is gone. Third problem: When programming the board, you need to remove the new connection at pin 39. Otherwise programming will fail. To avoid all these problems, why not use UART1 and connect the smart card to expansion port pin 57? Here's the expansion port layout http://www.ethernut.de/en/hardware/enut1/ports.html (Do not mount R33! This is for UART1 routed to the DB-9 only.) For the software use NutRegisterDevice(&DEV_UART1, 0, 0); fp = fopen(DEV_UART1_NAME, "r+"); fread(fp,....); The big advantage is, that you don't need to modify the hardware and UART0 at the DB-9 connector is still available. Harald _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: UART0 receive problemPrasad.Nagapati@... wrote:
> But I am getting random data, what could be the reason, do I need an > inverter before connecting to the Rx of UART1? Typically not, but could be. I'm not familiar with smart cards. > Please help me regarding this. Sample code below IMHO, this code is too complicated for testing. I recommend to remove everything which is not related to the smart card sniffing. Remove all the network stuff. Simply use DEV_DEBUG with stdio to output the data. If you still get random data with minimalist code, then most likely the problem is not caused by a bug in your application. Harald _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: UART0 receive problemOn Thu, Jun 11, 2009 at 02:12:18PM +0800, Prasad.Nagapati@... wrote:
> > Hi Harald, > > As you mentioned I am using UART1 now, and connected it to directly the > smart card I/O line which operates at +5V. > Smart card settings are 9600, 8 data bit, Even parity, 1 stop bit. Even > I configured the same in my code also. > > But I am getting random data, what could be the reason, do I need an > inverter before connecting to the Rx of UART1? Random data ist usually a problem of false settings. A scope is a good tool to find out if timing and levels are Ok. Parity can be difficult to verify unless you send single characters. I never saw the requirement for an inverter. All devices normaly agree that high level is idle. So you should measure 5V is nothing is send. Some devices however disable their driver in some situations to allow multiple slaves. Therefor it is usually a good idea to enable the pull-up on the RX line. Normaly I programm the uart myself and don't use Ethernet code for it, so I can comment on your code. -- B.Walter <bernd@...> http://www.bwct.de Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm. _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: UART0 receive problemPrasad.Nagapati@... wrote:
> But I am getting random data, what could be the reason, do I need an > inverter before connecting to the Rx of UART1? Typically not, but could be. I'm not familiar with smart cards. > Please help me regarding this. Sample code below IMHO, this code is too complicated for testing. I recommend to remove everything which is not related to the smart card sniffing. Remove all the network stuff. Simply use DEV_DEBUG with stdio to output the data. If you still get random data with minimalist code, then most likely the problem is not caused by a bug in your application. Harald _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
| Free embeddable forum powered by Nabble | Forum Help |