I am working on an arduino uno + supercollider 3 project.
Basicly: I have an arduino set up with potentiometers, a sensor and some buttons. I put the data of inputs in an array and send it to my computer trough serial.
Currently, my output in the Arduino serial monitor is as this:
271:189:75:0:0:0:1:0:0:0:0:0
If I open the serial connection in Supercollider, what arrives is this:
271
Only the first value in the array arrives correctly. (The same setup with just 1 Arduino input to Supercollider worked like a charm, by the way. I just can't get it working with an array of inputs from arduino to SC3.)
arduino code to send data at this moment:
teSturen = String(val_lichtPin) + ":" + String(val_Pot1Pin) + ":" + String(val_Pot2Pin) + ":" + String(val_Pot3Pin) + ":" + String(val_Pot4Pin) + ":" + String(val_Pot5Pin) + ":" + String(knop1Staat) + ":" + String(knop2Staat) + ":" + String(knop3Staat) + ":" + String(knop4Staat) + ":" + String(knop5Staat) + ":" + String(knop6Staat);
Serial.println(String(teSturen));
I put all the numbers together in one string with an : as seperator, then send this.
SC3 code to receive:
~ino = ArduinoSMS("/dev/ttyACM0",9600);
~ino.action = {
arg msg;
var amsg;
//amsg = msg.split($:);
msg.postln;
};
There is more code, but that is for appointing vars and args, defining synths, et cetera. I limited this to the bits where it doesn't work.
Any ideas on why SC3 only receives the first number? I have tried for example to recplace the seperator : by , or ;, to send it as multiple integers in stead of one string, ...
The goal of it for me, is to be able to control various synths in supercollider with fysical control potentiometers, because that's a lot more fun to play with than keyboard or mouse controlling synths...
I appreciate any help, thank you!
Pretty late, but this still might help. I used the same setup some years ago. I used
p = ArduinoSMS("/dev/tty.usbmodem3d11", 115200);
while{state==0}{
p.action = { |... msg| m=[msg[0],msg[1]];
do something with m[0] and m[1] ...
};
to parse the message stream. My setup only read arrays of two bytes (msg[0]and msg[1]), but this should be expandable.
The full source code is available on https://github.com/symbolrush/FridgeKiller and another project with the same setup on https://github.com/symbolrush/ColliDuino.
Hope this helps and good luck!
Related
We have a web project which is always working fine, it just using codename one push api to push notification to our devices, but it suddenly get the following error:
javax.net.ssl.SSLHandshakeException: Received fatal alert:
handshake_failure
Below is the core code (same with codenamoe one demo)
HttpURLConnection connection = (HttpURLConnection)new URL("https://push.codenameone.com/push/push").openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
String cert = ITUNES_DEVELOPMENT_PUSH_CERT;
String pass = ITUNES_DEVELOPMENT_PUSH_CERT_PASSWORD;
if(ITUNES_PRODUCTION_PUSH) {
cert = ITUNES_PRODUCTION_PUSH_CERT;
pass = ITUNES_PRODUCTION_PUSH_CERT_PASSWORD;
}
String query = "token=" + PUSH_TOKEN +
"&device=" + URLEncoder.encode(deviceId1, "UTF-8") +
"&device=" + URLEncoder.encode(deviceId2, "UTF-8") +
"&device=" + URLEncoder.encode(deviceId3, "UTF-8") +
"&type=1" +
"&auth=" + URLEncoder.encode(FCM_SERVER_API_KEY, "UTF-8") +
"&certPassword=" + URLEncoder.encode(pass, "UTF-8") +
"&cert=" + URLEncoder.encode(cert, "UTF-8") +
"&body=" + URLEncoder.encode(MESSAGE_BODY, "UTF-8") +
"&production=" + ITUNES_PRODUCTION_PUSH +
"&sid=" + URLEncoder.encode(WNS_SID, "UTF-8") +
"&client_secret=" + URLEncoder.encode(WNS_CLIENT_SECRET, "UTF-8");
try (OutputStream output = connection.getOutputStream()) {
output.write(query.getBytes("UTF-8"));
}
int c = connection.getResponseCode();
// read response JSON
I directly run the code in unit test, it works well.
But when I call the function from project (such as a button from webpage), the error happened.
I tried several way to solve it but still can not work, please give me some suggestion to fix the issue. Thank you!
This generally happens if the certificate is invalid or out of date etc. It can happen if your connection. I just verified our SSL certificate on the push servers and it's valid (generated by cloudflare) so I suggest checking the routes to the server and your version of Java. You should have Java 8 or newer with a recent enough minor update version.
When signing a transaction,I have copied the scriptPubKey from previous referenced transaction (for script field in input) and appended the hash-type.
Then in the original transaction,I have replaced the script with scriptSig and removed the hash-type.
Raw Transaction.
But,when I check the transaction is coinb.in,it says that the transaction is not signed.
The code I'm using to generate is inspired from Ken Shirriff's blog and Shlomi's video on youtube
My version of the code can be found here
Snippet which populates the transaction is here:
def get_real_transaction(self,account):
sigscript = self.generate_sig_script(account)
self.real_transaction = ""
self.real_transaction = (
self.version
+ self.txn_inputs_count
+ self.txn_inputs[0]["output_hash"]
+ self.txn_inputs[0]["output_index"]
+ self.txn_inputs[0]["sigScriptBytes"]
+ self.txn_inputs[0]["sigScript"]
+ self.txn_inputs[0]["sequence"]
+ self.txn_outputs_count
+ self.txn_outputs[0]["value"]
+ self.txn_outputs[0]["scriptPubKeyBytes"]
+ self.txn_outputs[0]["scriptPubKey"]
+ self.locktime
)
return self.real_transaction
Entire transaction.py is here
Any guidance/hints will be extremely helpful.
Recently i got into MEL programming to help out a few friends in maya. They wanted to have their files refferenced on a server, so i needed to change the reff strings. Now i have compiled a solution to do this, and used another example as a guide, but when i run the script it says
// Error: int $nt=tokenize $TexturePath "\" $buff;
//
// Error: Line 12.43: Unterminated string. //
What gives?
p.s. full code below for anyone who wants to use it
string $SceneTextures[] = `ls -tex`;
string $plus="";//Place a file type here to be saved in that subfolder
for ($i = 0; $i< (`size $SceneTextures`); $i++)
{
$Test = catchQuiet(`getAttr ($SceneTextures[$i] + ".fileTextureName")`);
if ($Test == 0)
{
string $TexturePath = `getAttr ($SceneTextures[$i] + ".fileTextureName")`;
string $buff[];
int $nt=`tokenize $TexturePath "\\" $buff`;
string $newPath=("${ARC_SURF}\\" + plus + "\\" + $buff[$nt-3] + "\\" + $buff[$nt-2] + "\\" + $buff[$nt-1]);
setAttr -type "string" ($SceneTextures[$i] + ".fileTextureName") $NewPath;
catchQuiet (AEfileTextureReloadCmd ($SceneTextures[$i] + ".fileTextureName"));
//print $TexturePath;
}//end if
}//end for i
EDIT: Fixed the code as it should be, now it only throws // Error: line 14: Invalid negative index used to reference array "$buff".
But i think that probably only 1 texture screws stuff up, will check and report back
I'm no expert in MEL, but in many languages \ is used to escape control-sequences, so I would guess you want "\\" instead of "\", in the many places it appears.
I'm trying to make a bukkit plugin and I can't seem to find any documentation on this but I've seen it done, How would I input commands into a chat message that a user could click on to execute a command on the server like "/motd" in the form of a clickable link like a URL
if (commandLabel.equalsIgnoreCase("cmd") {
player.sendMessage("Pick a command: " + </motd> + ", " + </mail> );
}
replacing "" and "" to output something like this:
Pick a command: MOTD, Mail
and clicking them would execute the command to the server as them. How would I do this?
You could do it like this:
IChatBaseComponent comp = ChatSerializer
.a("{\"text\":\"" + "Choose one: " + "\",\"extra\":[{\"text\":\"" + "MOTD" + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" + "/motd" + "\"}}]}");
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) <player>).getHandle().playerConnection.sendPacket(packet);
This would send them a message showing:
Choose one: MOTD
and when the user clicked MOTD, it would run the command /motd as the player. Here's a little breakdown of what we're actually doing:
IChatBaseComponent comp = ChatSerializer
.a("{\"text\":\"" + "<Ignored Message> " +
"\",\"extra\":[{\"text\":\"" + "<Message that will be clicked>" +
"\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" +
"<Command to be run when message is clicked>" + "\"}}]}");
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) <player>).getHandle().playerConnection.sendPacket(packet);
The above code will send the player:
<Ignored Message> <Message that will be clicked>
and when the player clicks <Message that will be clicked>
they will run the command <Command to be run when a message is clicked>, and because it does not start with the command prefix, /, it will force them to chat <Command to be run when a message is clicked>.
Unfortunately, as far as I know, you can only put one click event per message, so you would have to do something like this:
Choose one:
MOTD
Mail
So you would have to do, where the variable player is the player:
player.sendMessage("Choose one:");
IChatBaseComponent comp = ChatSerializer
.a("{\"text\":\"" +
"\",\"extra\":[{\"text\":\"" + "MOTD" +
"\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" +
"/motd" + "\"}}]}");
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
IChatBaseComponent comp2 = ChatSerializer
.a("{\"text\":\"" +
"\",\"extra\":[{\"text\":\"" + "Mail" +
"\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" +
"/mail" + "\"}}]}");
PacketPlayOutChat packet2 = new PacketPlayOutChat(comp2, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet2);
When MOTD is clicked, /motd will be run by the player, and when Mail is clicked, /mail will be run.
Just as a side note, you will need to include craftbukkit in your build path, along with bukkit to do this
Or you could simply just do this (I did my own, You can edit it)
/execute #a ~ ~ ~ tellraw #p ["",{"text":"Click this to die","color":"dark_red","bold":true,"clickEvent":{"action":"run_command","value":"/kill #p"},"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"Kills you!"}]}}}]
run_command can be replaced with Open URL too.
You can replace dark red with any colour too. You can replace true with false for bold if you want, /kill #p can be replaced with a command (Or a https:// link if you do Open URL, show_text can be replaced with Show Item, Show entity, or Show Achivement. Text & Kills you can be replaced with the different thing (eg, Show entity) (Entity replaces text)
I found a website if your stuck! Good day :) http://minecraftjson.com/
How can I get Mathematica to export/save/write a text file with proper Fortan77 formatting, that is, 72 columns and a continuation marker on the sixth column?
I am using Mathematica to generate large and complex analytic expressions, which I then need to insert into pre-existing Fortran77 code. I have everything working correctly in the front end of Mathematica with FortranForm[] and
SetOptions[$Output, PageWidth -> 72]
However, I can't figure out how to get Mathematica to output correctly to a text file. I want something like this:
MM11 = mH1**2 + (g2**2*v1**2)/2. -
- (g2**2*(v1**2/2. -
- ((v2*Cos(phi2) - (0,1)*v2*Sin(phi2))*
- (v2*Cos(phi2) + (0,1)*v2*Sin(phi2)))/2.))/2.
...
but get either this:
MM11 = FortranForm[mH1^2 + (g2^2*v1^2)/2 - ...
or this:
MM11 = mH1**2 + (g2**2*v1**2)/2. - (g2**2*
(v1**2/2. - ((v2*Cos(phi2) - (0,1)*v2*Sin(phi2))*
...
This is a job for the surprisingly little-known Splice function. First, you make a template file, with the extension ".mf", like so:
file = "test.mf";
out = OpenWrite[file];
WriteString[out, "MH1 = <* form *>"];
Close[out];
Now when you use Splice, Mathematica will automatically replace everything between the <* and *> delimiters with its evaluated form. So if you set
form = 4 + b9^2 + c1^5 + c4^5 + h10^4 + j2 + k10^4 + p10^4 + q5^5 +
q8 + s3^3 + s7^2 + t6^3 + u3^2 + u9^3 + x8^4 + z2^3;
and call
Splice["test.mf", PageWidth -> 72];
which will automatically infer you want FortranForm output from the file extension, and which allows you to set PageWidth as an option, you will get a pretty decent result in the automatically generated file "test.f" (note the new extension):
MH1 = 4 + b9**2 + c1**5 + c4**5 + h10**4 + j2 + k10**4 + p10**4 +
- q5**5 + q8 + s3**3 + s7**2 + t6**3 + u3**2 + u9**3 + x8**4 +
- z2**3
Look at the docs for Splice for more options (changing the name of the output file and the like).