Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Hi All!

to communicate with pumps in a test rig, I use a RS232 bricklet. Communication seems alright when I use BrickViewer and was already able to send commands and recieve data (see image).

image.png.79402f2f1afc0329428c285d6e633a20.png

As future communication should be run by a MATLAB script, I tried sending the same command in the following code (derived from the RS232 Bricklet Example), which did not work at all. 

clear
clc
import com.tinkerforge.IPConnection;
import com.tinkerforge.BrickletRS232V2;
import java.lang.String;

HOST = 'localhost';
PORT = 4223;
UID = 'MyUID'; % Change XYZ to the UID of your RS232 Bricklet 2.0

ipcon = IPConnection(); % Create IP connection
rs232 = BrickletRS232V2(UID, ipcon); % Create device object
ipcon.connect(HOST, PORT); % Connect to brickd

rs232.disableReadCallback();
rs232.write(String('OUT_SP_1 100').toCharArray());
ipcon.disconnect();

I also tried adding \r\n to the char, which also did not work. Can you tell, where my fault is? 

bearbeitet von j.wagner96

Geschrieben

Try this.

clear
clc
import com.tinkerforge.IPConnection;
import com.tinkerforge.BrickletRS232V2;
import java.lang.String;

HOST = 'localhost';
PORT = 4223;
UID = 'MyUID'; % Change XYZ to the UID of your RS232 Bricklet 2.0

ipcon = IPConnection(); % Create IP connection
rs232 = BrickletRS232V2(UID, ipcon); % Create device object
ipcon.connect(HOST, PORT); % Connect to brickd

% make sure the Bricklet has the expected configuration
rs232.setConfiguration(9600, BrickletRS232V2.PARITY_NONE, BrickletRS232V2.STOPBITS_1, BrickletRS232V2.WORDLENGTH_8, BrickletRS232V2.FLOWCONTROL_OFF);

rs232.disableReadCallback();
rs232.write(String('OUT_SP_1 100\r\n').toCharArray());
ipcon.disconnect();
Geschrieben
  • Autor

Thanks for your help! Manually setting the configuration sadly didn't have an effect and the device does not react to any commands sent by the matlab script.

bearbeitet von j.wagner96

Geschrieben
  • Autor

That seems right, but there's still no reaction of the device. 

 

EDIT: Found the error.

Instead of adding the CR and LF like in your advice

rs232.write(String('OUT_SP_1 100' + char(13) + char(10)).toCharArray());

, concatenate it like so: 

rs232.write(String(['OUT_SP_1 100' char(13) char(10)]).toCharArray());

that worked - at least - for me.

bearbeitet von j.wagner96

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.