Receiving data from Scanner via serial port - serial-port

I want to receive data from a scanner through a serial port.
My scanner is connected to a EPT (Electronic Paiment Terminal) on COM0.
The scanner seems to work fine, I can detect barcodes and QrCodes but nothing is received on serial PORT.
Every scanner I tried ended with the same result, but I managed to receive data from other devices.
Is there any specificities about that kind of devices ?
On EPT side, serial port is formated as the scanner dialog (115200, 8, N, 1 with no flow control)
I can receive data from the scanner to a computer and from computer to the EPT.
I have tried with two different scanner:
- HoneyWell 3310G
- Posline PS-75
I work on a IWL250 and a IUC180B. Both are EPT made by INGENICO. Both react in the same way.
On EPT, I have to use a C API given by the constructor of the machine.
Below my test code :
if(IsCOM0()){
if(stdcom0() == 0)
hCom0 = Telium_Fopen("COM0", "rw");
else
hCom0 = stdcom0();
Telium_Format("COM0", 115200, 8, 1, NO_PARITY, EVEN, 0);
Telium_Send_receive(hCom0, ON, ON);
iRet = Telium_Ttestall(COM0, 0);
iRet = Telium_Ttestall(COM0, 0);
do{
j = Telium_Fread(&test[i++], 1, 1, hCom0);
}while(j > 0);
Telium_Fclose(hCom0);
}
With every devices except the scanner i have, Telium_Ttestall detect an event on COM0 and I can read data in &test.
Thanks in advance

Nevermind,
We have solved the issue. The wire we were using was not made correctly.
Sorry for disturbing.
Best Regards,

Related

nRF52840 is ignoring certain setWriteCallback() calls

so I just started experimenting with the Adafruit Feather nRF52840 board and have set up a working BLE connection between the board and another device.
Usually, everything works fine by sending data from the other device to the nRF52840, but sometimes, if I send 2 packets at the exact same time, the setWriteCallback is only registering one of them.
Is there a way I can work around this issue?
This is how I set up my callback in code:
void charact_write_callback(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t *data, uint16_t len)
{
if(data[0] == 2){
Serial.print(data[1] == 0 ? "Left" : "Right");
Serial.println(" Hand Touch occured");
}
}
When both hands are actually touching and sending data to the device, this callback only receives one.
Thanks in advance and Greetings

Sim800L lag/delay before incoming calls are visible to arduino

I use SIM800L GSM module to detect incoming calls and generally it works fine. The only problem is that sometimes it takes up to 8 RINGS before the GSM module tells arduino that someone is calling (before RING appears on the serial connection). It looks like a GSM Network congestion but I do not have such issues with normal calls (I mean calls between people). It happens to often - so it cannot be network/Provider overload. Does anybody else had such a problem?
ISP/Provider: Plus GSM in Poland
I don't put any code, because the problem is in different layer I think
sorry that I didn't answer earlier. I've tested it and it turned out that in bare minimum code it worked OK! I mean, I can see 'RING' on the serial monitor immediately after dialing the number. So it's not a hardware issue!
//bare minimum code:
void loop() {
if(serialSIM800.available()){
Serial.write(serialSIM800.read());
}
if(Serial.available()){
serialSIM800.write(Serial.read());
}
}
In my real code I need to compare calling number with the trusted list. To do that I saved all trusted numbers in the contact list on the sim card (with the common prefix name 'mytrusted'). So, in the main loop there's if statement:
while(mySerial.available()){
incomingByte = mySerial.read();
inputString += incomingByte;
}
if (inputString.indexOf("mytrusted") > 0){
isTrusted = 1;
Serial.println("A TRUSTED NUMBER IS CALLING");
}
After adding this "if condition" Arduino sometimes recognize trusted number after 1'st call, and sometimes after 4'th or 5'th. I'm not suspecting the if statement itself , but the preceding while loop, where incoming bytes are combined into one string.
Any ideas, what can be improved in this simply code?
It seems, I found workaround for my problem. I just send a simple 'AT' command every 20 seconds to SIM800L (it replies with 'OK' ). I use timer to count this 20 seconds interval (instead of simply delay function)
TimerObject *timer2 = new TimerObject(20000); //AT command interval
....
timer2->setOnTimer(&SendATCMD);
....
void SendATCMD () {
mySerial.println("AT");
timer2->Stop();
timer2->Start();
}
With this simple modification Arduino always sees incoming call immediately (after 1 ring)

Passing data to arduino through windows command line

Im attempting to play with sending data to my arduino and keep running into the same problem. The code on the arduino is as follows:
void setup()
{
Serial.begin(9600);
for (int i = 3; i <= 13; i++)
{
pinMode(i, OUTPUT);
digitalWrite(i, LOW);
}
}
void loop()
{
if (Serial.available())
{
char ch = Serial.read();
int it = ch - '0';
digitalWrite(it, HIGH);
delay(1000);
digitalWrite(it, LOW);
}
}
This basically makes it so when you send a character over the serial monitor to the device it lights up the light connected to the specified pin for one second.
In the built in serial monitor this works fine, you send the device a number 1-9 (haven't figured out how to do 10+ yet) and the specified light turns on, just as intended. However, my goal is to write a c++ program to send data to the device using the system() command from windows.h. Before i can do that i need the command to send data to the device. I found:
echo i > COM1 //with i being the number to be sent over
Well i tried that and got a fairly interesting result half the time i would receive this message in the command line:
C:/users/XXXXX> echo 7 > COM3 //im 100% sure im using com3
Access is denied
The other half of the time i would see the data go through (The RX light would light up) but nothing would happen, the light connected to pin 7 wouldn't light up. I immedatly thought that you might need to pass the data in ASCII, but nope,
echo 55 > COM3
produced the same result. If any one knows how to send data over window command line to arduio i would really appreciate it, thanks.
Welp after no response here and 7 more hours of research i finally found the solution to my problem here. basically from command line do
powershell //to enter powershell
$port= new-Object System.IO.Ports.SerialPort COM#,Baudrate,None,8,one
//to create a new port object
$port.open() //to open a connection
$port.WriteLine(data)
$port.close()
Looks like the key thing is that you cant just send raw data over to the arduino, you need to first open a connection before with the arduino before it will actually recognize the data as valid serial input.
update:
If you want to run it from command line all you need to do is write a powershell script like so:
$com = $args[0]
$baud = $args[1]
$write = $args[2]
$port = $port= new-Object System.IO.Ports.SerialPort $com,$baud,None,8,one
$port.open()
$port.write($write)
$port.close()
Which can then be called from the command line and have the arguments passed like so:
powershell.exe -ExecutionPolicy Bypass -file filelocation/test.ps1 COM3 2400 7
I had a similar problem.
First, the "Access is denied" error is caused by the Serial Monitor holding the port.
Second, simply "echoing" a string will not work properly, because you also send along the line termination.
The trick is to send something like this:
set /p x="A" <nul >\\.\COM4
Source:
https://batchloaf.wordpress.com/2013/02/12/simple-trick-for-sending-characters-to-a-serial-port-in-windows/

Two xbee beacons drowning each other out?

I'm trying to create a pair of arduino/xbee beacons that will transmit some information (ultimately GPS coordinates) to each other at all times. The problem is that when they're both on, neither one seems to receive. I'm guessing it's because both might be transmitting at the same time and drowning the others message out. However, I'm not sure of a better approach since neither one is a slave or master. Here's my setup:
Hardware:
A pair of XBee-Pro 900 XSC S3B xbees.
A pair of teensy (arduino compatible with multiple UARTs)
XBee Setup
VID: 542D
DT: 8153
Serial connected to Serial 3 on Teensy
Code
long lastTxTime = 0
void setup() {
Serial.begin(9600);
Serial3.begin(9600);
}
void loop() {
long now = millis();
// Send ever 0.5 seconds
if (now - lastTxTime > 500) {
Serial.println("SEND!");
Serial3.println("WOOT!");
lastTxTime = now;
}
delay(100);
// Print anything received
while(Serial3.available()) {
char c = Serial3.read();
Serial.print(c);
}
}
When I connect both Teensy's to separate terminals, both of them output "SEND" and rarely receive a "WOOT". I put one of the XBees straight on a USB board to a terminal and it output most of the "WOOT" messages from the other.
What can I do to make this work?
What you need to look into is flow control. In the wireless standard, they use RTS (Request to Send) & CTS (Clear to Send). The RTS/CTS pins on Xbee might be what you need,

SMS is truncated when I read it from Siemens TC35 GSM module and Arduino

I'm doing some experiments with Arduino+Siemens TC35 GSM module and I would like to be able to read an SMS that I send to this device.
I have assembled my device following more or less this scheme:
with the difference that I don't use a buzzer nor a relay, just an LCD display. You can see the full picture here:
The scheme should work, because for example I have been able to send an SMS from Arduino to my mobile phone, but I'm having some problems parsing the SMS I send to my Arduino.
(note: I will hide my number substituting some numbers with ***)
I initialize the GSM module like this:
mySerial.print("AT+CMGF=1\r\n");
and I try to read my SMS like this:
void readSMS()
{
mySerial.print("AT+CMGR=6\r\n");
delay(1000);
char c;
while (mySerial.available()>0){
c = (char)mySerial.read();
Serial.print(c);
}
}
but I always get a truncated SMS. This is what I see in my Serial monitor:
AT+CMGF=1
OK
AT+CMGR=6
+CMGR: "REC READ","AT+CMGR=6
+CMGR: "REC READ","+4475********",,"14/04/25,21:08:AT+CMGR=6
+CMGR: "REC READ","+4475********",,"14/04/25,21:08:AT+CMGR=6
+CMGR: "REC READ","+4475********",,"14/04/25,21:08:AT+CMGR=6
+CMGR: "REC READ","+4475********",,"14/04/25,21:08:AT+CMGR=6
what's wrong with my code?
Thank you so much for any help.
p.s: also other commands that are supposed to work (for example the one to delete all SMS: AT+CMGD=1,4) don't work at all and give me error.
p.p.s: I wish I could use the GSM.h library that is available for Arduino, but I guess it's only compatible with the original Arduino GSM Shield.
I'm not an Arduino expert in any capacity, so there may be better ways to do this in the API, but I'd try something like this (delays can probably be lowered)
void readSMS()
{
mySerial.print("AT+CMGR=6\r\n"); // Send request
int count = 5; // Number of 100ms intervals before
// assuming there is no more data
while(count-- != 0) { // Loop until count = 0
delay(100); // Delay 100ms
while (mySerial.available() > 0){ // If there is data, read it and reset
c = (char)mySerial.read(); // the counter, otherwise go try again
Serial.print(c);
count = 5;
}
}
}
Another - probably better - option would be to just loop without a delay until you get a complete answer. That of course assumes that you know what to look for (<cr><lf>OK<cr><lf> would seem to be the case here, but I'm too weak on the Hayes spec to be sure)

Resources