Old 10-08-2013, 02:18 PM   #1
benioff
Human being with feelings
 
Join Date: Oct 2013
Location: NYC
Posts: 3
Default urgent! a loop in Reascript crashes Reaper

hi all-- new to the forum, but have been using reaper for a while now. we are building an exhibit for a conference that goes up next week (tuesday oct 15, 2013). it plays coupled sounds and movies of earthquakes, and we have built an arduino-based Earthquake Control Box that sends four commands to the serial bus to run REAPER through a ReaScript--- so in the script we call pySerial to read what is coming in from the serial bus. Using REAPER 4.3.1 and python 2.7.5 on a Mac (OSX 10.6.8). Code sample is below.
I have isolated the problem (i believe) to the loop in the ReaScript that must be there somehow to always look for events coming in from the controller to trigger the ActionNumbers. I know the pySerial works as i can get the strings in (when the loop is turned off). And I can run the necessary action numbers triggered by the strings. When i try to implement a loop (example below), the whole user interface freezes up and I need to Force Quit. I have found threads that say that Reaper doesnt like an infinite loop (ReaScript: About the "possibly infinite loop" error message...) , so i fixed that, and that there is a limit to the number of ActionNumbers, so we just run the loop with a delay (time.sleep) to try to get it to work for now.

Has anyone had this problem? Does anyone know why loops are causing so much trouble ? This thread also seems relevant: http://forum.cockos.com/showthread.php?t=127977
We think we need a loop to be running to look for input from the controller, but if there are any other ways of making that work, please let us know!
Thanks very very much-- ben

"
import sys
import os.path
import subprocess
import serial
import time

from reaper_python import *

Version = sys.version_info
RPR_ShowConsoleMsg(str(Version))
# DEFINE THE USB PORT:
ser = serial.Serial('/dev/tty.usbmodem621', 9600)
x = ser.readline()
RPR_ShowConsoleMsg(str(x))

for i in range(10000):
time.sleep(0.5)
x = ser.readline()

if x.startswith("L"):
msg = "go back one EQ"
actionNum = 40172 # Markers: Previous marker/project start
RPR_Main_OnCommand(actionNum, 0)
RPR_ShowConsoleMsg(msg)
"
benioff is offline   Reply With Quote
Old 10-09-2013, 08:07 PM   #2
benioff
Human being with feelings
 
Join Date: Oct 2013
Location: NYC
Posts: 3
Default followup--

could this be a problem originating with pySerial ? not with REAPER and ReaScript ?
benioff is offline   Reply With Quote
Old 10-09-2013, 10:57 PM   #3
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

hi benioff and welcome to the forums!

The freeze is expected: all actions incl. macros & script are performed from the main thread and you do not not to put it to Sleep(t) or in an infinite loop (!)
You want the deserialization to run in a dedicated thread.
Jeffos is offline   Reply With Quote
Old 10-11-2013, 01:46 PM   #4
benioff
Human being with feelings
 
Join Date: Oct 2013
Location: NYC
Posts: 3
Default thanks!

thank you !! we switched to OSC and it works beautifully..
a python script running outside reaper in an infinite loop, talking to the arduino...
then sending commands in when they happen--
benioff is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:56 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.