CCLib icon indicating copy to clipboard operation
CCLib copied to clipboard

python 2.7 or later is asking for me to encode

Open vprithiviraj opened this issue 9 years ago • 19 comments

when i'm trying to get the chip information by using cc_info.py through cygwin or command prompt terminal. it is telling that unicode strings are not supported, please encode to bytes: '▒\x00\x00\x00 It is telling encode to bytes. Not able to identify what is the error happened only i'm new to the python language help me in some way.

vprithiviraj avatar Oct 05 '16 14:10 vprithiviraj

Hello @vprithiviraj , can you tell me on which file is this error? Unfortunately I don't have any windows machine around and I cannot debug this.

wavesoft avatar Oct 05 '16 14:10 wavesoft

here with i attached which are all the lines the terminal is showing like that. i tried to run in cygwin terminal. there i didn't get the detailed information about those things. so i did wite the MS command prompt and gave you as a screenshot.

thanks in advance q2

vprithiviraj avatar Oct 05 '16 16:10 vprithiviraj

Ok, it looks that there is a system exception somewhere and the error message is not on english. I guess you are using a non-english windows system?

For a quick solution, I would say to open cc_info.py, go to line 30 and change what's in the print parenthesis with:

("uERROR: %s" % unicode(e))

let me know if this helps

wavesoft avatar Oct 05 '16 17:10 wavesoft

python 2.7.11 is recommended only know?

I have to install that package first dude..

vprithiviraj avatar Oct 05 '16 17:10 vprithiviraj

Yes, I could spend some time to make this code compatible with python 3.x there is not much work needed. Thanks for reporting this 👍

wavesoft avatar Oct 05 '16 17:10 wavesoft

thanks for your patience. Actually it took some time for installation of python 2.7.11. now the different error came comparing before. i hope u can understand by below screenshot q3

vprithiviraj avatar Oct 05 '16 18:10 vprithiviraj

It looks you are missing the serial python module. Make sure to run the following in the project folder in order to install everything:

pip install -r requirements.txt

Ps. Check this section on the readme: https://github.com/wavesoft/CCLib#2-prepare-your-software

wavesoft avatar Oct 05 '16 20:10 wavesoft

i have installed the pyserial using the above mentioned command before only. but still that error is coming.

i downloaded separate pyserial as exe format and installed after that also same error.

vprithiviraj avatar Oct 06 '16 03:10 vprithiviraj

It sounds like PYTHONPATH is not defined in your environment, so python doesn't know where to look for modules. Have a look here: https://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-7

wavesoft avatar Oct 06 '16 08:10 wavesoft

NO.. it is not happening now also dude. same error of last screenshot i shared you

it is telling only about the module named as serial is not available. so will i be able to clear the output by adding the python script in the folder where i copied all these cc debugging python scripts.

is there any particular location i should keep all the cc debugging python scripts for make the serial to get detected??

q4

i tried with cygwin terminal also after doing all this for observing error it is giving like that. so there i found different like in the screenshot i attached above

vprithiviraj avatar Oct 06 '16 09:10 vprithiviraj

can you respond for this when you are free?

vprithiviraj avatar Oct 07 '16 06:10 vprithiviraj

Hey @vprithiviraj , it seems that something is going wrong with your python installation. From a quick google search I found this, which I am not sure it's helpful : http://stackoverflow.com/questions/18946286/python3-installed-successfully-but-cannot-be-opened-in-terminal

So, one thing to check is that your PYTHONPATH variable points to the same version of the directory that your python version. Ex. dont use the Python 3.x modules when running Python 2.x.

One last thing that you could try is to use virtualenv to create an isolated environment with only what you want, properly installed:

  • Go to the project folder and type virtualenv env
  • This will create a folder env that contains a sandboxed version of the python modules
  • Activate that environment, typing env\Scripts\activate
  • Install again the correct modules typing pip install -r requirements.txt
  • Try to run the scripts again (try also running them like python ci_info.py COM12)
  • When you are done, close the window or type deactivate to deactivate the sandbox

wavesoft avatar Oct 07 '16 06:10 wavesoft

today i cleared all my python errors araised. but not it is telling could not read from the serial port. So what can be possibilities for this??

vprithiviraj avatar Oct 07 '16 14:10 vprithiviraj

A few things:

  1. First the obvious, make sure it's correctly connected and you see the COM port in the windows devices.
  2. Make sure you are using the correct port (use the arduino IDE -> Open the Serial Monitor and see if it succeeds).
  3. Make sure you have flashed the correct thing to your arduino.

Also, can you paste a screenshot with the error. I want to see if this is an exception or an error with your set-up.

wavesoft avatar Oct 07 '16 17:10 wavesoft

Hi, i was not able to get back to my work bcoz of festival holidays. now i have shared the screenshot of the error. kindly look into that. q5

when i didn't connect the arduno Uno, the com port the error will look like the second response

And also i'm doubtful that i'm using HM-10 breakout module for this work. if any inbulit HM-10 firmware is dumped in the breakout board. then whether it will make any restrictions to read the information from the Chip???

vprithiviraj avatar Oct 12 '16 05:10 vprithiviraj

Hi Mr.wavesoft, Can you look into my problem? is there any possibility problem with the arduino sketch i dumped in Arduino Uno. Please let me know if you found any solution for this.

Thanks in advance.

vprithiviraj avatar Oct 27 '16 08:10 vprithiviraj

Hello @vprithiviraj . From both of these errors it looks that there is something wrong with the communication between your PC and your Arduino. Unfortunately I haven't tested this code on windows and I am not 100% sure that this is not purely a library issue.

What I see is the following:

  1. The cc_info.py opens the COM11 port successfully
  2. The program sends a PING message. From the looks of it, the transmission succeeded
  3. Then it tries to read a response, but it reads nothing (perhaps the other end closed the port?). That's why you see the Could not read from the serial port! error.
  4. Then either the library doesn't close the port properly, or the Arduino board has some failure and when it tries to open the port again, it fails with Could not open port COM11 error.

Just to confirm, you have flashed the CCLib_proxy example to your Arduino right? Something else you can try is to close the Arduino IDE before trying to run the cc_info.py, just in case it keeps some COM port open.

wavesoft avatar Oct 31 '16 15:10 wavesoft

Hey @vprithiviraj , did you have any success eventually? I will get access to a windows computer soon, so I can properly debug this on windows tool. Otherwise, I will close this issue.

wavesoft avatar Dec 24 '16 12:12 wavesoft

did you have any success eventually?

no I have not got any success. COM port error only use to come for me always

i bought the module from https://www.fasttech.com/products/0/10004051/3875400-cc2541-bluetooth-4-0-ble-transparent-serial-data this module is having inbuilt HM-10 firmware. Will that firmware disturb our operation. actually before i thought our process will erase and write our new program inside. but, now i'm suspecting that one may create the issue of COM port error. @wavesoft

vprithiviraj avatar Dec 25 '16 13:12 vprithiviraj