# How can i uses this script from igniton v 7.9 to ignition 8.1 to load recipe

**URL:** <https://forum.inductiveautomation.com/t/how-can-i-uses-this-script-from-igniton-v-7-9-to-ignition-8-1-to-load-recipe/84598>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [January 22, 2024, 11:19pm UTC](https://forum.inductiveautomation.com/t/how-can-i-uses-this-script-from-igniton-v-7-9-to-ignition-8-1-to-load-recipe/84598 "2024-01-22T23:19:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jose\_Rodolfo\_Mutuc](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@Jose\_Rodolfo\_Mutuc](https://forum.inductiveautomation.com/u/Jose_Rodolfo_Mutuc)\
**Post date:** [January 22, 2024, 11:19pm UTC](https://forum.inductiveautomation.com/t/how-can-i-uses-this-script-from-igniton-v-7-9-to-ignition-8-1-to-load-recipe/84598/1 "2024-01-22T23:19:44Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/2/320f4e82d4bb49a7a99987e11c7a0b355bf7cbf2.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 22, 2024, 11:57pm UTC](https://forum.inductiveautomation.com/t/how-can-i-uses-this-script-from-igniton-v-7-9-to-ignition-8-1-to-load-recipe/84598/2 "2024-01-22T23:57:06Z")

</div>

Please post formated code, not pictures of code. See [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

Tip: when posting images crop them. 75% of your screenshot is whitespace.

---

<div class="post-metadata">

**Author:** ![Jose\_Rodolfo\_Mutuc](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@Jose\_Rodolfo\_Mutuc](https://forum.inductiveautomation.com/u/Jose_Rodolfo_Mutuc)\
**Post date:** [January 23, 2024, 12:05am UTC](https://forum.inductiveautomation.com/t/how-can-i-uses-this-script-from-igniton-v-7-9-to-ignition-8-1-to-load-recipe/84598/3 "2024-01-23T00:05:10Z")

</div>

```auto
		
def loadRecipe(recipe):
	# Setup the command
	cmd = 'AE LoadSetup,' + recipe
	
	# Send the load request
	log.debugf('Issue recipe load for %s', recipe)
	resp = project.rasco.serial.sendCmd(cmd)
	
	return resp

```

```auto
def sendCmd(command):

	# Open Serial	
	try:
		open()
	except:
		log.warnf('Unable to open RS232 connection on %s', port)
		return False

	command = start + command + end
	system.serial.write(port,hello)
	log.trace('Wrote hello to RS232')
	try:
	
		x = system.serial.readUntil(port,ready,False)
		log.trace('Received ready from RS232')
		
		system.serial.write(port,command)	
		log.tracef('Wrote %s to RS232', command)	
		
		x = system.serial.readUntil(port,hello,False)
		log.trace('Received hello from RS232')
		
		system.serial.write(port,ready)
		log.trace('Wrote ready to RS232')
		
		resp = system.serial.readUntil(port,end,False)
		resp = "".join([i for i in resp if ord(i) in range(32, 127)])
		
	except:
		log.warnf('Failed to execute %s to RS232', command)
		close()
		return False
	
	log.debugf('Executed %s to RS232', command)
	
	# Close serial
	close()
	
	return resp

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 23, 2024, 12:17am UTC](https://forum.inductiveautomation.com/t/how-can-i-uses-this-script-from-igniton-v-7-9-to-ignition-8-1-to-load-recipe/84598/4 "2024-01-23T00:17:11Z")

</div>

{ Please don't start new topics with the same question. }

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 23, 2024, 2:55am UTC](https://forum.inductiveautomation.com/t/how-can-i-uses-this-script-from-igniton-v-7-9-to-ignition-8-1-to-load-recipe/84598/5 "2024-01-23T02:55:47Z")

</div>

Consider removing (at least temporarily) those `try` / `except` clauses to see what it is that's breaking. If the resulting exception isn't obvious, post it here, and perhaps we can interpret it for you.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [January 23, 2024, 8:29am UTC](https://forum.inductiveautomation.com/t/how-can-i-uses-this-script-from-igniton-v-7-9-to-ignition-8-1-to-load-recipe/84598/6 "2024-01-23T08:29:42Z")

</div>

A few things about this code though:

1. it uses variables that are not defined there (`start`, `end`...).  
It doesn't mean it will not work, they might be globals. It means you need to be extra careful with them.
2. did you define the `close` and `open` functions ?  
I'd advise not to do that, as they're built-in python functions. Try not to overwrite built-in stuff.
3. I'd also suggest using `close` in a `finally` clause, if there's no context manager for `open`.
4. It seems you're returning a string in case of success, and `False` in case of error.  
I suggest you avoid mixing types, and return `None` instead in case of error.  
Or, if the calling function needs to know an error happened... let it handle the exceptions.
