compared to plus 1 the com port 2 is not behaving correctly. we got a serial camera attached and it does not get any data when we asked for it or when we write a buffer it just hangs!!! (Baud rate 115200)
Com2 on the plus 2
#1
Posted 11 January 2013 - 02:08 PM
#2
Posted 11 January 2013 - 02:38 PM
#3
Posted 11 January 2013 - 03:12 PM
cant test on another com port as its a sheild. Works fine the plus 1 and there are a few deployed at our customers
One the plus 2 it seems the debugging is terrible. you step over while bugging and nothing happens!!! its hard to explain
I wish i never brought the plus 2 now but no where stocked the plus 1. im a tight dead line and these kind of hassles is not what i need right now!
#4
Posted 11 January 2013 - 03:15 PM
byte[] outbuff = new byte[] { 0x56, 0x00, 0x32, 0x0C, 0x00, 0x0A, 0x00, 0x00, bPos1, bPos2, 0x00, 0x00, bLen1, bLen2, bdelay1, bdelay2 }; int numPackets = imagelength / 496; if (imagelength > (numPackets * 496)) numPackets += 1; byte[] imageData = new byte[imagelength]; for (int i = 0; i < numPackets; i++) { int pos = i*496; // Ask for the next packet outbuff[8] = (byte)(pos >> 8); outbuff[9] = (byte)(pos & 0xFF); serialPort.Write(outbuff, 0, outbuff.Length); int bytesToRead = 506;
as soon as you step over the last line, thats it! no more debugging and the program has crashed!
#5
Posted 11 January 2013 - 03:24 PM
Hi Ash,
Could you please specify the serial port settings you are using? That way I could try if the same happens here.
Also, a tip from my side; if you really need NP1s, they're still available (at Adafruit for the USA or Floris.cc for the EU), and I haven't seen an end of life notice yet. I -think- they're still in production. If you need them for commercial applications, I'm sure you could make a deal (and maybe even for better pricing?) by contacting secret labs.
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#6
Posted 11 January 2013 - 03:47 PM
Adafruit was the place we got the plus 2's from because no where in the UK had enough stock and no stock of the plus 1's. We went for the Plus 2 thinking it would be a direct drop in replacement.
The funny thing is ive put my shield back on the plus 1 and its working as well as can be expected. Stick on the plus 2 the com2 and debugging is a nightmare.
Com 2 is set to 38400 initally until i set up the camera and the camera the baud rate to use is 115200. Then i close the port, change the baud rate and then re-open it. Any other comms after returns 0 bytes to read!
#7
Posted 11 January 2013 - 03:51 PM
Hi Ash,
I'm sorry to say but you're making it very difficult for me to help you out here.
How have you configured the serial port; I'm not only interested to the baud rate but also stopbit setting, parity, etc.
Could you post the serialport constructor, and if you have two (you changed the baud rate in your code?), post both of them?
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#8
Posted 11 January 2013 - 04:17 PM
serialPort = new SerialPort("COM2", 38400, Parity.None, 8, StopBits.One);
hi, sorry. its noting special
#9
Posted 11 January 2013 - 04:18 PM
changing the baud rate
public bool ChangeBaudRate(Baud baudRate) { byte b1= 0x2A,b2= 0xF2; switch (baudRate) { case Baud.B57600: b1 = 0x1C; b2 = 0x4C; break; case Baud.B115200: b1 = 0x0D; b2 = 0xA6; break; } byte[] outbuff = new byte[] { 0x56, 0x00, 0x24, 0x03, 0x01, b1, b2 }; serialPort.Write(outbuff, 0, 7); byte[] inbuff = WaitForResponse(5, 50); if ((inbuff[0] == 0x76) && (inbuff[2] == 0x24)) { serialPort.Close(); serialPort.BaudRate = 115200; serialPort.Open(); return true; } return false; }
#10
Posted 11 January 2013 - 04:19 PM
Adafruit was the place we got the plus 2's from because no where in the UK had enough stock and no stock of the plus 1's. We went for the Plus 2 thinking it would be a direct drop in replacement.
Have to tried Proto-Pic. At the time of posting they are reporting 10 N+1 in stock and only 1 N+2. In fact they are the only UK supplier I can find with N+2's in stock.
Regards,
Mark
To be or not to be = 0xFF
Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life
Follow @nevynuk on Twitter
#11
Posted 11 January 2013 - 04:28 PM
thanks mark but with we need more than 10 and need to get this working on the 2's as it will benefit everyone as there is an issue here. like i said it works fine the np1 and falls over on the np2.
#12
Posted 11 January 2013 - 04:32 PM
#13
Posted 11 January 2013 - 04:49 PM
i dont a small project which basically sets up the camera, takes a pic and returns the pic as a byte array and yes the same issue is there.
public byte[] GetImageData(int imagelength) { byte bdelay1 = 0x00; byte bdelay2 = 0x0A; byte bPos1 = 0x00; byte bPos2 = 0x00; // datalength of 496. Camera transfer maximum 512 bytes at a time. Each packet has 5 bytes at the start and 5 at the end // and the datalength must be a multiple of 8. So 496 is the biggest we can have byte bLen1 = 0x01; byte bLen2 = 0xF0; byte[] outbuff = new byte[] { 0x56, 0x00, 0x32, 0x0C, 0x00, 0x0A, 0x00, 0x00, bPos1, bPos2, 0x00, 0x00, bLen1, bLen2, bdelay1, bdelay2 }; int numPackets = imagelength / 496; if (imagelength > (numPackets * 496)) numPackets += 1; byte[] imageData = new byte[imagelength]; for (int i = 0; i < numPackets; i++) { int pos = i*496; // Ask for the next packet outbuff[8] = (byte)(pos >> 8); outbuff[9] = (byte)(pos & 0xFF); serialPort.Write(outbuff, 0, outbuff.Length); int bytesToRead = 506; if ((imagelength - pos) < 496) { bytesToRead = (imagelength - pos) + 10; } WaitForData(bytesToRead, 100, imageData, pos); } StopPic(); return imageData; }
as i step over the code the debug line dissapear when i do a serial.write and it looks like the system has crashed as there is nothing else i can do!
#14
Posted 11 January 2013 - 07:40 PM
#15
Posted 14 January 2013 - 12:20 PM
I dont think its the com port as i did a loop back test and it seemed ok but 100% sure.
Attached Files
#16
Posted 23 January 2013 - 04:44 AM
Are you using flow control? What's the state of /CTS when you do the SerialPort.Write()? What kind of camera?
Try placing a try...catch around the SerialPort.Write(), very rarely I've seen this trap an exception that the debugger's unhandled exception trap did not.
I think in your shoes I would try capturing the last few serial interactions on a scope, using both the N+1 and the N+2 and examine them side by side. If you see a difference in the two traces, that would at least give you a starting point.
Good luck to you, I hope you're able to track down the problem.
#17
Posted 22 April 2013 - 10:41 PM
We have the same problem but we found the issue. The serial communication with the camera works ok when the ethernet port is NOT connected. Once a ethernet port is connected to the network the issue appears again. (even if the ethernet libraries are not used)
This problem occurs in the NP2 and Fez Cobra I, but it does not occur in the fez panda II with ethernet shield.
When the ethernet cable is connected only small data transfer work ok, but large data transfers fail.
Any ideas how to fix this bug???
Thank you
Pedro
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users