Cannot connect Photoresearch PR655 to PC using Psychopy, Communication Protocol Problem?

Dear Sir or Madam;

I cannot connect Photoresearch PR655 to PC (Win64) with an USB cable using Psychopy.
Is it possible that, the communication protocol of PR655 has changed, leading to that, the psychopy cannot detect the PR655 device? OR ** The win system cannot be win64 **?

The monitor center of psychopy cannot scan any photometer, as shown below.

I use Psychopy 2021.2.3 with codes like “PhotoResearch — PsychoPy v2021.2”.
The spectrascan PR655 driver has been installed from offical website: Handheld SpectraScan® Spectroradiometer (380–780 nm; 3.12 nm) | PR-655 | JADAK

The original program is attached below:

from psychopy.hardware.pr import PR655
myPR655 = PR655(‘COM3’)
myPR655.getLum() # make a measurement
nm, power = myPR650.getLastSpectrum() # get a power spectrum for the last measurement

or

from psychopy import hardware
phot = hardware.findPhotometer()
print(phot.getLum())

How should I do to connect PR655 TO computer?

I appreciate very much if anyone could help!

Thank you very much!

BEST WISHES!

Hi There,

Please could you try this script to see if that works? PR655.py (4.0 KB)

It looks like there is a problem connecting to the port. If you click on monitor center :monitor_center: then choose PR655 in that drop down it should try to scan all ports to find the photometer - can you give that a go?

Thanks,
Becca

Dear Dr. Becca,
Thank you very much for your reply. YEAH, it shoud be the problem of port connection. By checking Computer Management>> Device Manager>>port(COM and LPT)>>PRI instrument (COM3), re-pluging the USB port, the connection problem still could not be solved. I am sorry about that.

And, I should try to think about other ways, maybe.

Really thank you very much
Jiang

Dear Becca and All,
Is it possible that the communication protocol of PR655 has changed, in comparison with the code on PhotoResearch — PsychoPy v2021.2 ? Since the communication protocol of PR655 has changed, the old code, which was based on previous protocol, cannot communicate/connect the new purchased PR655 with a computer?
Thanks.

It is possible things have changed since the code but they should not have changed if you communicate via monitor centre - if you use monitor center and scan all ports for the PR655 does it find it?

Thanks,
Becca

Dear Becca, really thank you very much for the reply. I used Psychopy>>Tool>>monitor center, and checked the button of “Get Photometer” and the result is as attached above, no photometers found.

I donot know why. My PC is WIN10, -64, USB cable.
I tried using another .exe software (not based on Python) to connect the PR655, it does work.
It’s rather confusing of the problem.

Thanks again for your answer.
Best

Dear Jiang9 and Becca

I’ve been struggling with the same problem over a year, and I wonder if you have found a solution.

PsychoPy3 fails to find PR-655 both on Windows and Macs (Intel), but there used to be a compromise as PsychoPy2 worked on either platform (though with some problems on Win), and the calibration file can be copied into PP3. However, now I must find another way as PsychoPy2 does not run well on recent macOS (32-bit issue?).

As PP2 works, physical connection and OS drivers should be fine.
But it looks beyond my skill to check all the PsychoPy codes and supporting libraries.
Any advice or information, from anybody around, would be much appreciated.

Hiroshi

I am sorry that I still cannot solve it.
It is also beyond my skill to check the PsychoPy codes and supporting libraries.
Previously, I had successfully connect it when I re-install my computer with a win7–32 system.
It’s rather confusing.
Hope any one could solve our problem.a

Best wishes

Dear Jiang9,

Thank you for your reply!
So something might be wrong with the 64-bit part, not the PsychoPy codes themselves. PsychoPy2 was built as a 32-bit app, and while it still runs under 64-bit Windows, it doesn’t under full-64bit macOS.
This doesn’t help but may give us a clue.

Best wishes,
Hiroshi

Dear All,

I’m coming close to the cause of the problem.

PR-655 is driven by the script ‘pr.py’ (in ‘hardware’ subfolder of psychopy scripts.).
In PsychoPy2, the class PR655 had a separate ‘sendMessage’ to have this part:

        for letter in message:
            # for PR655 have to send individual chars ! :-/
            self.com.write(letter)
            self.com.flush()

In PsychoPy3 (incl. 2021.2.3), this function is deleted, and sendMessage defined for PR650 is used.
As written in the comment, PR650 seem to require sending chars one by one.
I have copy-pasted sendMessage from PR650 into PR655 (pasted before startRemoteMode), and modified the lines for serial writing.

    def sendMessage(self, message, timeout=0.5, DEBUG=False):
        """Send a command to the photometer and wait an allotted
        timeout for a response (Timeout should be long for low
        light measurements)
        """
        if message[-1] != '\n':
            message += '\n'  # append a newline if necess

        # flush the read buffer first
        # read as many chars as are in the buffer
        self.com.read(self.com.inWaiting())

        # send the message
        if type(message) != bytes:
            for m in message:
                self.com.write(m.encode('utf-8'))
                self.com.flush()
            # self.com.write(message.encode('utf-8'))
        else:
            for b in message:
                self.com.write(b)
                self.flush()
        self.com.flush()
        # time.sleep(0.1)  # PR650 gets upset if hurried!

        # get feedback (within timeout limit)
        self.com.timeout = timeout
        logging.debug(message)  # send complete message
        if message in ('d5\n', 'D5\n'):
            # we need a spectrum which will have multiple lines
            reply = self.com.readlines()
            if PY3:
                reply = [thisLine.decode('utf-8') for thisLine in reply]
        else:
            reply = self.com.readline()
            if PY3:
                reply = reply.decode('utf-8')
        return reply

And now my photometer responds! This works both on my intel Mac and Win10 PC, though editing files on Win is tricky as I don’t really understand the privileges.

I hope someone in the team can fix it (maybe in a more appropriate way) in the future updates.

1 Like

I’m just leaving this here but this trick does not seem to work with the PR670 on a machine whereas PTB3 routines work fine.

I’m in the middle of doing a new class for the PR670 and psychopy but I’m hoping someone who uses pr.py has taken a look. As a reference, pr.pyc works fine with our PR670 on a Raspberry Pi.

I use linux.

Hi @hashtagcpt - Any progress? Did you see this issue: Hang when attempting to message a PR670 under Linux · Issue #1698 · psychopy/psychopy · GitHub ?

For anyone looking to find this later - it looks like this was the commit that removed the special case for the PR655.

I’ve opened a review here.

This is reported as being fixed, here: PR655 failure to detect · Issue #5237 · psychopy/psychopy · GitHub